diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2012-02-28 23:26:08 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2012-02-28 23:26:08 -0800 |
commit | 0e1b6b6f1e2ea9b420e148b3faf65c34790b7bcd (patch) | |
tree | e592ca341abb97fb349a60122d2c33eb01f24c60 /match.c | |
parent | 9c70c2b50bb44aebcd2d01e605d7712492c7de0e (diff) | |
download | txr-0e1b6b6f1e2ea9b420e148b3faf65c34790b7bcd.tar.gz txr-0e1b6b6f1e2ea9b420e148b3faf65c34790b7bcd.tar.bz2 txr-0e1b6b6f1e2ea9b420e148b3faf65c34790b7bcd.zip |
* 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.
Diffstat (limited to 'match.c')
-rw-r--r-- | match.c | 14 |
1 files changed, 8 insertions, 6 deletions
@@ -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); + } } } |