Commits

Anonymous committed 3eaa53e

optimization paranoia

Comments (0)

Files changed (4)

-let some x = Some x
-
 (** пропустить значение последовательно через функции:
     123 >> string_of_int >> print_string
 *)
       byte land 0b11_000_000 = 0b10_000_000
 
     and bad_tail =
-      some & Bad_utf8 "tail != 0x80..0xBF"
+      Some (Bad_utf8 "tail != 0x80..0xBF")
     ;
 
 
           if byte < 0x80
           then loop ~ch:(ch+1) ~i:(i+1)
           else if byte <= 0xBF
-          then (ch, i, some & Bad_utf8 "head 0x80..0xBF")
+          then (ch, i, Some (Bad_utf8 "head 0x80..0xBF"))
           else if byte <= 0xC1
           then
             (if relaxed_utf8.val
              then skip_tail ~ch ~i ~sz:2
-             else (ch, i, some & Bad_utf8 "head 0xC0..0xC1 (overlong)")
+             else (ch, i, Some (Bad_utf8 "head 0xC0..0xC1 (overlong)"))
             )
           else if byte < 0xE0
           then skip_tail ~ch ~i ~sz:2
           then skip_tail ~ch ~i ~sz:3
           else if byte <= 0xF4
           then skip_tail ~ch ~i ~sz:4
-          else (ch, i, some & Bad_utf8 "head 0xF5..0xFF")
+          else (ch, i, Some (Bad_utf8 "head 0xF5..0xFF"))
       and skip_tail ~ch ~sz ~i =  (* check len, then check_tail *)
         if i + sz > sc_len
         then (ch, i, None)
         else
           let codepoint = decode_4bytes a b c d in
           if codepoint > 0x10FFFF
-          then (ch, i, some & Bad_utf8 "codepoint > 0x10FFFF")
+          then (ch, i, Some (Bad_utf8 "codepoint > 0x10FFFF"))
           else loop ~ch:(ch+1) ~i:(ifrom+4)
       in
         loop ~ch:0 ~i:0
        mres (read_func inch buf_str 0 buffer_size) >>% fun read_res ->
        match read_res with
        [ `Error e ->
-           k (EOF (some & ierr_of_merr e)) >>% fun (it, sl') ->
+           k (EOF (Some (ierr_of_merr e))) >>% fun (it, sl') ->
            IO.return (it, lazy sl', EP_None)
        | `Ok have_read ->
            (* let () = fdbg "ep: Read buffer, size %i" have_read in *)
       byte land 0b11_000_000 = 0b10_000_000
 
     and bad_tail =
-      some & Bad_utf8 "tail != 0x80..0xBF"
+      Some (Bad_utf8 "tail != 0x80..0xBF")
     ;
 
 
           if byte < 0x80
           then loop ~ch:(ch+1) ~i:(i+1)
           else if byte <= 0xBF
-          then (ch, i, some & Bad_utf8 "head 0x80..0xBF")
+          then (ch, i, Some (Bad_utf8 "head 0x80..0xBF"))
           else if byte <= 0xC1
           then
             (if relaxed_utf8.val
              then skip_tail ~ch ~i ~sz:2
-             else (ch, i, some & Bad_utf8 "head 0xC0..0xC1 (overlong)")
+             else (ch, i, Some (Bad_utf8 "head 0xC0..0xC1 (overlong)"))
             )
           else if byte < 0xE0
           then skip_tail ~ch ~i ~sz:2
           then skip_tail ~ch ~i ~sz:3
           else if byte <= 0xF4
           then skip_tail ~ch ~i ~sz:4
-          else (ch, i, some & Bad_utf8 "head 0xF5..0xFF")
+          else (ch, i, Some (Bad_utf8 "head 0xF5..0xFF"))
       and skip_tail ~ch ~sz ~i =  (* check len, then check_tail *)
         if i + sz > sc_len
         then (ch, i, None)
         else
           let codepoint = decode_4bytes a b c d in
           if codepoint > 0x10FFFF
-          then (ch, i, some & Bad_utf8 "codepoint > 0x10FFFF")
+          then (ch, i, Some (Bad_utf8 "codepoint > 0x10FFFF"))
           else loop ~ch:(ch+1) ~i:(ifrom+4)
       in
         loop ~ch:0 ~i:0
 value destruct_first_item s =
   if s.len = 0
   then None
-  else some &
-    (s.arr.(s.ofs), C.mk ~arr:s.arr ~ofs:(s.ofs+1) ~len:(s.len-1))
+  else Some (
+    (s.arr.(s.ofs), C.mk ~arr:s.arr ~ofs:(s.ofs+1) ~len:(s.len-1)))
 ;
 
 value sub s ~ofs ~len =
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.