SF.net SVN: geany-plugins:[1260] trunk/geanygendoc/src/ggd-tag-utils.c

colombanw at users.sourceforge.net colombanw at xxxxx
Tue Apr 20 20:55:17 UTC 2010


Revision: 1260
          http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=1260&view=rev
Author:   colombanw
Date:     2010-04-20 20:55:17 +0000 (Tue, 20 Apr 2010)

Log Message:
-----------
GeanyGenDoc: Improve tag search for a given line

Make ggd_tag_find_from_line() use only a linear search rather than
sorting the tag array and then doing an almost linear search.
Benefits are probable speed improvement (array sorting isn't a cheap
operation) and no more modification of the given tag array.

Modified Paths:
--------------
    trunk/geanygendoc/src/ggd-tag-utils.c

Modified: trunk/geanygendoc/src/ggd-tag-utils.c
===================================================================
--- trunk/geanygendoc/src/ggd-tag-utils.c	2010-04-19 21:26:52 UTC (rev 1259)
+++ trunk/geanygendoc/src/ggd-tag-utils.c	2010-04-20 20:55:17 UTC (rev 1260)
@@ -80,17 +80,10 @@
   
   g_return_val_if_fail (tags != NULL, NULL);
   
-  /* FIXME: try to use an algorithm that doesn't need to have a sorted array.
-   *        it would be faster (well, array sorting is probably everything but
-   *        fast) and better as we wouldn't touch the array */
-  /* sort the array to have the lines in the right order */
-  g_ptr_array_sort (tags, tag_cmp_by_line);
-  /* FIXME: use dichotomy rather than a linear search? */
   PTR_ARRAY_FOR (tags, i, el) {
     if (! (el->type & tm_tag_file_t)) {
-      if (el->atts.entry.line > line && tag) {
-        break;
-      } else {
+      if (el->atts.entry.line <= line &&
+          (! tag || el->atts.entry.line > tag->atts.entry.line)) {
         tag = el;
       }
     }


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Plugins-Commits mailing list