[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[5882] don't use regexp search to parse a node
From: |
Gavin D. Smith |
Subject: |
[5882] don't use regexp search to parse a node |
Date: |
Wed, 22 Oct 2014 20:21:53 +0000 |
Revision: 5882
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=5882
Author: gavin
Date: 2014-10-22 20:21:51 +0000 (Wed, 22 Oct 2014)
Log Message:
-----------
don't use regexp search to parse a node
Modified Paths:
--------------
trunk/ChangeLog
trunk/info/info-utils.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2014-10-21 17:07:12 UTC (rev 5881)
+++ trunk/ChangeLog 2014-10-22 20:21:51 UTC (rev 5882)
@@ -1,3 +1,10 @@
+2014-10-22 Gavin Smith <address@hidden>
+
+ * info/info-utils.c (forward_to_info_syntax): New function.
+ (scan_node_contents): Call it instead of using regexp_search.
+ This produces a speed improvement, noticable when using M-x
+ index-apropos or opening a long index node.
+
2014-10-21 Karl Berry <address@hidden>
* tp/texi2any.pl (makeinfo_help),
Modified: trunk/info/info-utils.c
===================================================================
--- trunk/info/info-utils.c 2014-10-21 17:07:12 UTC (rev 5881)
+++ trunk/info/info-utils.c 2014-10-22 20:21:51 UTC (rev 5882)
@@ -1580,6 +1580,26 @@
free (expansion);
}
+#define looking_at_string(contents, string) \
+ (!memcmp (contents, string, strlen (string)))
+
+static char *
+forward_to_info_syntax (char *contents)
+{
+ while (contents < input_start + input_length)
+ {
+ /* Menu entry comes first to optimize for the case of looking through a
+ long index node. */
+ if (looking_at_string (contents, INFO_MENU_ENTRY_LABEL)
+ || looking_at_string (contents, INFO_MENU_LABEL)
+ || looking_at_string (contents, INFO_XREF_LABEL)
+ || !memcmp (contents, " \b[", 3))
+ return contents;
+ contents++;
+ }
+ return 0;
+}
+
/* Scan (*NODE_PTR)->contents and record location and contents of
cross-references and menu items. Convert character encoding of
node contents to that of the user if the two are known to be
@@ -1590,12 +1610,8 @@
void
scan_node_contents (FILE_BUFFER *fb, NODE **node_ptr)
{
- char *search_string;
- long position;
- regmatch_t *matches;
- size_t match_count;
- size_t i;
int in_menu = 0;
+ char *match;
NODE *node = *node_ptr;
@@ -1654,24 +1670,12 @@
parse_top_node_line (node);
- search_string = INFO_MENU_REGEXP "|" INFO_MENU_ENTRY_REGEXP
- "|" INFO_XREF_REGEXP "|" INFO_TAG_REGEXP;
-
- if (regexp_search (search_string, 0, 1, node->contents, node->nodelen,
- &matches, &match_count)
- == search_success)
- for (i = 0; i < match_count; i++)
+ while ((match = forward_to_info_syntax (inptr))
+ && match < node->contents + node->nodelen)
{
int in_parentheses = 0;
REFERENCE *entry;
- char *match;
- position = matches[i].rm_so;
- match = node->contents + position;
-
- if (match < inptr)
- continue;
-
/* Write out up to match */
copy_input_to_output (match - inptr);
@@ -1715,6 +1719,8 @@
add_pointer_to_array (entry, refs_index, refs, refs_slots, 50);
}
+ else
+ copy_input_to_output (1);
}
/* If we haven't accidentally gone past the end of the node, write
@@ -1729,8 +1735,6 @@
/* Free resources used in character encoding conversion. */
close_conversion ();
- free (matches);
-
node->references = refs;
if (rewrite_p)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [5882] don't use regexp search to parse a node,
Gavin D. Smith <=