nitlanguage
/
nit.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
9c213bd
)
lib/core: Improve FlatBuffer re-allocation rate by pre-allocating at least 16 bytes
author
Lucas Bajolet
<r4pass@hotmail.com>
Fri, 29 Apr 2016 20:15:24 +0000
(16:15 -0400)
committer
Lucas Bajolet
<r4pass@hotmail.com>
Tue, 3 May 2016 03:25:22 +0000
(23:25 -0400)
Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>
lib/core/text/flat.nit
patch
|
blob
|
history
diff --git
a/lib/core/text/flat.nit
b/lib/core/text/flat.nit
index
0fc5663
..
2533323
100644
(file)
--- a/
lib/core/text/flat.nit
+++ b/
lib/core/text/flat.nit
@@
-933,12
+933,13
@@
class FlatBuffer
do
var c = capacity
if cap <= c then return
- while c <= cap do c = c * 2 + 2
+ if c <= 16 then c = 16
+ while c <= cap do c = c * 2
# The COW flag can be set at false here, since
# it does a copy of the current `Buffer`
written = false
var bln = _bytelen
- var a = new NativeString(c+1)
+ var a = new NativeString(c)
if bln > 0 then
var it = _items
if bln > 0 then it.copy_to(a, bln, 0, 0)