[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[6486] faster searching
From: |
Gavin D. Smith |
Subject: |
[6486] faster searching |
Date: |
Fri, 31 Jul 2015 21:41:35 +0000 |
Revision: 6486
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=6486
Author: gavin
Date: 2015-07-31 21:41:31 +0000 (Fri, 31 Jul 2015)
Log Message:
-----------
faster searching
Modified Paths:
--------------
trunk/ChangeLog
trunk/info/nodes.c
trunk/info/nodes.h
trunk/info/search.c
trunk/info/session.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2015-07-29 18:14:06 UTC (rev 6485)
+++ trunk/ChangeLog 2015-07-31 21:41:31 UTC (rev 6486)
@@ -1,3 +1,20 @@
+2015-07-31 Gavin Smith <address@hidden>
+
+ * info/nodes.c (info_node_of_tag, info_node_of_tag_ext): Rename
+ and add an extra argument. Call scan_node_contents
+ conditionally.
+ (info_node_of_tag, info_node_of_tag_fast): New functions.
+ * info/session.c (info_search_internal): Call
+ info_node_of_tag_fast to get node.
+ (info_search_in_node_internal): If there is a match, fetch the
+ node and do the search again.
+ (info_search_internal): Always free a node if it wasn't retained
+ in the window.
+
+ * info/nodes.h (N_Simple): New flag.
+ * info/session.c (regexp_search): Indicate search not found in
+ return value if that is the case.
+
2015-07-29 Gavin Smith <address@hidden>
* doc/texinfo.texi: Run M-x texinfo-master-menu in Emacs.
Modified: trunk/info/nodes.c
===================================================================
--- trunk/info/nodes.c 2015-07-29 18:14:06 UTC (rev 6485)
+++ trunk/info/nodes.c 2015-07-31 21:41:31 UTC (rev 6486)
@@ -1277,9 +1277,11 @@
}
/* Return the node described by *TAG_PTR, retrieving contents from subfile
- if the file is split. Return 0 on failure. */
-NODE *
-info_node_of_tag (FILE_BUFFER *fb, TAG **tag_ptr)
+ if the file is split. Return 0 on failure. If FAST, don't process the
+ node to find cross-references, a menu, or perform character encoding
+ conversion. */
+static NODE *
+info_node_of_tag_ext (FILE_BUFFER *fb, TAG **tag_ptr, int fast)
{
TAG *tag = *tag_ptr;
NODE *node;
@@ -1352,7 +1354,7 @@
set_tag_nodelen (subfile, tag);
}
- if (!tag->cache.nodename)
+ if (!tag->cache.nodename || (tag->cache.flags & N_Simple))
{
/* Data for node has not been generated yet. */
NODE *cache = &tag->cache;
@@ -1365,10 +1367,16 @@
if (parent != subfile)
cache->subfile = tag->filename;
- /* Read locations of references in node and similar. Strip Info file
- syntax from node if preprocess_nodes=On. Adjust the offsets of
- anchors that occur within the node.*/
- scan_node_contents (cache, parent, tag_ptr);
+ if (!fast)
+ {
+ /* Read locations of references in node and similar. Strip Info file
+ syntax from node if preprocess_nodes=On. Adjust the offsets of
+ anchors that occur within the node. */
+ scan_node_contents (cache, parent, tag_ptr);
+ cache->flags &= ~N_Simple;
+ }
+ else
+ cache->flags |= N_Simple;
if (!preprocess_nodes_p)
node_set_body_start (cache);
@@ -1412,3 +1420,15 @@
return node;
}
+
+NODE *
+info_node_of_tag (FILE_BUFFER *fb, TAG **tag_ptr)
+{
+ return info_node_of_tag_ext (fb, tag_ptr, 0);
+}
+
+NODE *
+info_node_of_tag_fast (FILE_BUFFER *fb, TAG **tag_ptr)
+{
+ return info_node_of_tag_ext (fb, tag_ptr, 1);
+}
Modified: trunk/info/nodes.h
===================================================================
--- trunk/info/nodes.h 2015-07-29 18:14:06 UTC (rev 6485)
+++ trunk/info/nodes.h 2015-07-31 21:41:31 UTC (rev 6486)
@@ -68,6 +68,7 @@
#define N_Subfile 0x800 /* File buffer is a subfile of a split file. */
#define N_EOLs_Converted 0x1000 /* CR bytes were stripped before LF. */
#define N_Gone 0x2000 /* File is no more. */
+#define N_Simple 0x4000 /* Data about cross-references is missing. */
/* String constants. */
#define INFO_FILE_LABEL "File:"
@@ -158,6 +159,7 @@
NODE *defaults);
extern NODE *info_node_of_tag (FILE_BUFFER *fb, TAG **tag_ptr);
+extern NODE *info_node_of_tag_fast (FILE_BUFFER *fb, TAG **tag_ptr);
/* Return a pointer to a NODE structure for the Info node NODENAME in
FILE_BUFFER. NODENAME can be passed as NULL, in which case the
Modified: trunk/info/search.c
===================================================================
--- trunk/info/search.c 2015-07-29 18:14:06 UTC (rev 6485)
+++ trunk/info/search.c 2015-07-31 21:41:31 UTC (rev 6486)
@@ -204,7 +204,10 @@
*matches_out = matches;
*match_count_out = match_count;
- return search_success;
+ if (match_count == 0)
+ return search_not_found;
+ else
+ return search_success;
}
/* Search forwards for STRING through the text delimited in BINDING. */
Modified: trunk/info/session.c
===================================================================
--- trunk/info/session.c 2015-07-29 18:14:06 UTC (rev 6485)
+++ trunk/info/session.c 2015-07-31 21:41:31 UTC (rev 6486)
@@ -3892,13 +3892,12 @@
/* Search for STRING in NODE starting at START. The DIR argument says which
direction to search in. If it is positive, search forward, else backwards.
- If the string was found, return its location in POFF, set the
- window's node to be NODE, its point to be the found string, and readjust
- the window's pagetop.
+ If the string was found, return its location in POFF, set the
+ window's node, its point to be the found string, and readjust
+ the window's pagetop. NODE can be retained as a field within WINDOW.
WINDOW->matches should be a list of matches for NODE->contents, or null.
- If new matches are calculated, they are saved in WINDOW->matches.
-*/
+ If new matches are calculated, they are saved in WINDOW->matches. */
static enum search_result
info_search_in_node_internal (WINDOW *window, NODE *node,
char *string, long start,
@@ -3938,6 +3937,24 @@
if (result != search_success)
return result;
+ if (node->flags & N_Simple)
+ {
+ /* There are matches in the node, but it hasn't been scanned yet. Get
+ the node again, because its contents may differ. */
+ enum search_result subresult;
+ NODE *full_node;
+
+ free (matches);
+ full_node = info_get_node (node->fullpath, node->nodename);
+ subresult = info_search_in_node_internal (window, full_node,
+ string, start,
+ dir, case_sensitive,
+ match_regexp, poff);
+ if (window->node != full_node)
+ free (full_node);
+ return subresult;
+ }
+
if (dir > 0)
{
if (start >= node->body_start)
@@ -4045,12 +4062,11 @@
result = info_search_in_node_internal (window, node, string, start, dir,
case_sensitive, use_regex, start_off);
+ if (node != window->node)
+ free_history_node (node);
+
if (result == search_invalid)
- {
- if (node != window->node)
- free_history_node (node);
- return 1;
- }
+ return 1;
if (result == search_success)
{
@@ -4102,12 +4118,10 @@
}
/* Get a new node to search in. */
- if (node != window->node)
- free_history_node (node);
free (window->matches);
window->matches = 0;
- node = info_get_node (file_buffer->filename, tag->nodename);
+ node = info_node_of_tag_fast (file_buffer, &tag);
if (!node)
{
/* If not doing i-search... */
@@ -4139,8 +4153,6 @@
info_error ("%s", _("Search failed."));
funexit:
- if (node != window->node)
- free_history_node (node);
return -1;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [6486] faster searching,
Gavin D. Smith <=