Nikhil Marathe avatar Nikhil Marathe committed 27940ce

Converted handle-bulk-reply to use case rather than if

Comments (0)

Files changed (1)

 (define (redis:handle-bulk-reply r)
   (letn ((parts (parse (r 2) redis:CRLF)) ; $n\r\n.*\r\n
         (reply-len (int (1 (parts 0)))))  ;<-^
-    (begin 
-      (if (= -1 reply-len)
-        (list "" (+ (length (parts 0)) (length (parts 1)) (length redis:CRLF))) ; length of $-1 + remnant
-        (begin
+    (case reply-len
+      (-1 (list "" (+ (length (parts 0)) (length (parts 1)) (length redis:CRLF)))) ; length of $-1 + remnant
+      (true (begin
           (if (<= reply-len (length (parts 1))) ; if we don't need to read more
-                (begin
-                  (letn ((replystring (0 reply-len (parts 1))) ; the .* part on the next line onwards
-                        (read-len (+ (length (parts 0))
+            (begin
+              (letn ((replystring (0 reply-len (parts 1))) ; the .* part on the next line onwards
+                     (read-len (+ (length (parts 0))
                                     reply-len
                                     (* 2 (length redis:CRLF))))) ; 2 times because \r\n on each line
-                    (list replystring read-len)))
+                (list replystring read-len)))
             (redis:read r)))))))
 
 (define (redis:handle-multi-bulk-reply r)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.