nitlanguage
/
nit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
benchmarks/string: Updated bench scripts for strings
[nit.git]
/
benchmarks
/
strings
/
array_to_s_vars
/
array_to_s_rope.nit
diff --git
a/benchmarks/strings/array_to_s_vars/array_to_s_rope.nit
b/benchmarks/strings/array_to_s_vars/array_to_s_rope.nit
index
c162dff
..
9f86a8a
100644
(file)
--- a/
benchmarks/strings/array_to_s_vars/array_to_s_rope.nit
+++ b/
benchmarks/strings/array_to_s_vars/array_to_s_rope.nit
@@
-13,19
+13,21
@@
# To be used as a Mixin at compile-time for benchmarking purposes.
module array_to_s_rope
# To be used as a Mixin at compile-time for benchmarking purposes.
module array_to_s_rope
+intrude import standard::collection::array
+intrude import standard::ropes
+
redef class Array[E]
redef fun to_s do
redef class Array[E]
redef fun to_s do
- var i = 1
var l = length
var l = length
+ var it = _items
if l == 0 then return ""
if l == 0 then return ""
- var s: String = new RopeString.from(self[0].to_s)
- var its = _items
- while i < l do
- var e = its[i]
- if e != null then s += e.to_s
- i += 1
+ if l == 1 then return it[0].to_s
+ var c = new Concat(it[0].to_s, it[1].to_s)
+ for i in [2 .. l[ do
+ c = new Concat(c, it[i].to_s)
end
end
- return s
+ return c
end
end
+
end
end