pike.git/
src/
builtin.cmod
Branch:
Tag:
Non-build tags
All tags
No tags
2014-08-27
2014-08-27 07:03:51 by Stephen R. van den Berg <srb@cuci.nl>
ba23875add8a9d36e467cb86f57329bbb4413e9b (
14
lines) (+
11
/-
3
)
[
Show
|
Annotate
]
Branch:
8.0
Reduce heap fragmentation even more.
3237:
sum += pos; shift |= str->str.known_shift; shift = shift & ~(shift >> 1);
-
if (
sum
> s->len
)
-
string_build_mkspace(&str->str,
sum - s->len
, shift);
+
j = sum - s->len;
+
if (
j>0) {
+
if (str->initial >
sum
)
+
j = str-
>
initial-
s->len
;
+
string_build_mkspace(&str->str,
j
, shift);
+
}
else if (shift != str->str.known_shift) string_build_mkspace(&str->str, 0, shift); s = str->str.s;
3360:
if( Pike_fp->current_object->flags & OBJECT_CLEAR_ON_EXIT ) s->flags |= STRING_CLEAR_ON_EXIT; push_string(s);
-
init_string_builder_alloc(&str->str,
str->initial
, 0);
+
// Pick a smaller size to minimise fragmentation
+
// addat() will expand if it notices reuse of
+
// the Buffer
+
init_string_builder_alloc(&str->str,
sizeof(struct svalue)
, 0);
} /*! @decl Buffer|void cut(int index, int|void end_or_none,void|int discard)