diff options
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | match.c | 14 |
2 files changed, 15 insertions, 6 deletions
@@ -1,5 +1,12 @@ 2012-02-28 Kaz Kylheku <kaz@kylheku.com> + * match.c (consume_prefix): This memory optimization should only + be done for lazy strings, otherwise it just causes unnecessary + memory use by duplicating the line, and inefficiency via + thanks to allocator churn. + +2012-02-28 Kaz Kylheku <kaz@kylheku.com> + * lib.c (numberp): Fix bad type check: null pointer dereference when object is nil. @@ -411,13 +411,15 @@ static val h_text(match_line_ctx *c) static void consume_prefix(match_line_ctx *c) { - const val shift_hiwater = num_fast(4000); - const val shift_amount = num_fast(3900); + if (lazy_stringp(c->dataline)) { + const val shift_hiwater = num_fast(4000); + const val shift_amount = num_fast(3900); - if (gt(c->pos, shift_hiwater)) { - c->base = plus(c->base, shift_amount); - c->pos = minus(c->pos, shift_amount); - c->dataline = sub_str(c->dataline, shift_amount, t); + if (gt(c->pos, shift_hiwater)) { + c->base = plus(c->base, shift_amount); + c->pos = minus(c->pos, shift_amount); + c->dataline = sub_str(c->dataline, shift_amount, t); + } } } |