From 846bd870808cedc6948ab8d3eb56197524512eaa Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Tue, 19 Dec 2017 13:23:10 -0500 Subject: [PATCH] rename Rope.iteri to Rope.each_byte --- lib/buf.ml | 2 +- lib/rope.ml | 7 +++---- lib/rope.mli | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/buf.ml b/lib/buf.ml index 9de0a6a..dfeba1c 100644 --- a/lib/buf.ml +++ b/lib/buf.ml @@ -73,7 +73,7 @@ let make_lexer buf = scanfn = buf.lexfn; lexbuf = Lexing.from_function (fun bytebuf n -> let count = ref 0 in - Rope.iteri (fun i c -> + Rope.each_byte (fun i c -> Bytes.set bytebuf !count (Char.chr c); incr count; (!count >= n)) buf.rope !pos; diff --git a/lib/rope.ml b/lib/rope.ml index 4b192c3..197192a 100644 --- a/lib/rope.ml +++ b/lib/rope.ml @@ -106,14 +106,13 @@ let rec each_rune fn rope pos = (******************************************************************************) -(* inefficient form of iteri *) -let rec iteri fn rope pos = +let rec each_byte fn rope pos = if pos < (length rope) && (fn pos (getb rope pos)) then - iteri fn rope (pos + 1) + each_byte fn rope (pos + 1) let gets rope i j = let buf = Bytes.create (j - i) in - iteri + each_byte (fun n c -> Bytes.set buf (n - i) (Char.chr c); (n <= j)) diff --git a/lib/rope.mli b/lib/rope.mli index 41598b5..ed40cb5 100644 --- a/lib/rope.mli +++ b/lib/rope.mli @@ -21,7 +21,7 @@ val flatten : rope -> rope val split : rope -> int -> (rope * rope) val del : rope -> int -> int -> rope -val iteri : (int -> rune -> bool) -> rope -> int -> unit +val each_byte : (int -> rune -> bool) -> rope -> int -> unit val each_rune : (int -> rune -> bool) -> rope -> int -> unit val getb : rope -> int -> int -- 2.52.0