nitlanguage
/
nit.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
f356e58
)
lib/standard/ropes: Added BufferLeaf to constructors.
author
Lucas Bajolet
<r4pass@hotmail.com>
Mon, 23 Jun 2014 15:23:33 +0000
(11:23 -0400)
committer
Lucas Bajolet
<r4pass@hotmail.com>
Thu, 24 Jul 2014 14:05:03 +0000
(10:05 -0400)
Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>
lib/bufferized_ropes.nit
patch
|
blob
|
history
diff --git
a/lib/bufferized_ropes.nit
b/lib/bufferized_ropes.nit
index
0dac054
..
0d9353e
100644
(file)
--- a/
lib/bufferized_ropes.nit
+++ b/
lib/bufferized_ropes.nit
@@
-25,4
+25,24
@@
private class BufferLeaf
end
+redef class Rope
+
+ # Empty Rope
+ init do root = new BufferLeaf(new FlatBuffer.with_capacity(buf_len))
+
+end
+
+redef class RopeString
+
+ init from(s: String) do
+ if s.length < buf_len then
+ var b = new FlatBuffer.with_capacity(buf_len)
+ b.append(s)
+ root = new BufferLeaf(b)
+ else
+ if s isa RopeString then root = s.root else root = new StringLeaf(s.as(FlatString))
+ end
+ end
+
+end