summaryrefslogtreecommitdiffstats
path: root/lib.h
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2012-03-01 01:05:05 -0800
committerKaz Kylheku <kaz@kylheku.com>2012-03-01 01:05:05 -0800
commit90fd6a84d08ac95f4886e6ae7e42429f75561bfa (patch)
tree9e5df1c2c6f30fa2d296785fedd39231e4efd85d /lib.h
parentaec0b3b3645d241ea8ad1f06dd64716b7d9c3c00 (diff)
downloadtxr-90fd6a84d08ac95f4886e6ae7e42429f75561bfa.tar.gz
txr-90fd6a84d08ac95f4886e6ae7e42429f75561bfa.tar.bz2
txr-90fd6a84d08ac95f4886e6ae7e42429f75561bfa.zip
Fixing two instances of unintentional O(n*n) behavior and poor memory use
that occur in horizontal matching of basic text patterns. * lib.c (match_str, match_str_tree): New functions. * lib.h (match_str, match_str_tree): Declared. * match.c (do_match_line): Use match_str_tree and match_str when matching strings and string lists, respectively, rather than stupidly calling search functions and then asserting that the match was found at the starting position.
Diffstat (limited to 'lib.h')
-rw-r--r--lib.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/lib.h b/lib.h
index 8c50eb9b..a143a128 100644
--- a/lib.h
+++ b/lib.h
@@ -425,6 +425,8 @@ val length_str(val str);
const wchar_t *c_str(val str);
val search_str(val haystack, val needle, val start_num, val from_end);
val search_str_tree(val haystack, val tree, val start_num, val from_end);
+val match_str(val bigstr, val str, val pos);
+val match_str_tree(val bigstr, val tree, val pos);
val replace_str(val str_in, val items, val from, val to);
val sub_str(val str_in, val from_num, val to_num);
val cat_str(val list, val sep);