lynx-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

lynx-dev a minimal optimization in SGMLFindTag (patch6)


From: Leonid Pauzner
Subject: lynx-dev a minimal optimization in SGMLFindTag (patch6)
Date: Sat, 19 Oct 2002 20:34:53 +0400 (MSD)

This is the last patch in my queue:


* in SGMLFindTag, we translate string uppercase in-place
  and launch case insensitive search. - LP



diff -u -p -w old/sgml.c ./sgml.c
--- old/sgml.c  Sun Oct  6 17:43:28 2002
+++ ./sgml.c    Sat Oct 19 20:32:54 2002
@@ -1377,15 +1377,20 @@ PRIVATE void start_element ARGS1(
 */
 PUBLIC HTTag * SGMLFindTag ARGS2(
        CONST SGML_dtd*,        dtd,
-       CONST char *,           string)
+       char *,         string)         /* will translate string uppercase */
 {
     int high, low, i, diff;
+    char * p = string;

+    for ( ; *p; p++)
+       *p = TOUPPER(*p);
+
+    /* now search case sensitively: */
     for (low = 0, high=dtd->number_of_tags;
         high > low;
         diff < 0 ? (low = i+1) : (high = i)) {  /* Binary search */
        i = (low + (high-low)/2);
-       diff = AS_casecomp(dtd->tags[i].name, string);  /* Case insensitive */
+       diff = AS_cmp(dtd->tags[i].name, string); /* Case sensitive */
        if (diff == 0) {                /* success: found it */
            return &dtd->tags[i];
        }
diff -u -p -w old/sgml.h ./sgml.h
--- old/sgml.h  Sat Jul  7 18:30:14 2001
+++ ./sgml.h    Fri Oct 18 21:08:52 2002
@@ -252,7 +252,7 @@ Find a Tag by Name
  */
 extern HTTag * SGMLFindTag PARAMS((
        CONST SGML_dtd *        dtd,
-       CONST char *            string));
+       char *          string));    /* will translate string uppercase */


 /*



; To UNSUBSCRIBE: Send "unsubscribe lynx-dev" to address@hidden

reply via email to

[Prev in Thread] Current Thread [Next in Thread]