[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: lynx-dev a minimal optimization in SGMLFindTag (patch6)
From: |
Leonid Pauzner |
Subject: |
Re: lynx-dev a minimal optimization in SGMLFindTag (patch6) |
Date: |
Sun, 20 Oct 2002 20:14:00 +0400 (MSD) |
>> This is the last patch in my queue:
> thanks (now I have several)
Sorry, one more patch, #7
> --
> Thomas E. Dickey <address@hidden>
Eliminate 1/3 heavy HTParse() calls.
(HTAnchor.c, HTParse.[c,h])
diff -u -p old/htanchor.c ./htanchor.c
--- old/htanchor.c Sun Oct 13 17:25:30 2002
+++ ./htanchor.c Sun Oct 20 18:34:28 2002
@@ -376,7 +376,7 @@ PUBLIC HTAnchor * HTAnchor_findAddress A
CONST DocAddress *, newdoc)
{
/* Anchor tag specified ? */
- char *tag = HTParse(newdoc->address, "", PARSE_ANCHOR);
+ char *tag = HTParseAnchor(newdoc->address);
CTRACE((tfp,"Entered HTAnchor_findAddress\n"));
@@ -384,7 +384,7 @@ PUBLIC HTAnchor * HTAnchor_findAddress A
** If the address represents a sub-anchor, we recursively load its
** parent, then we create a child anchor within that document.
*/
- if (*tag) {
+ if (tag && *tag) {
DocAddress parsed_doc;
HTParentAnchor * foundParent;
HTChildAnchor * foundAnchor;
diff -u -p old/htparse.h ./htparse.h
--- old/htparse.h Sun Oct 6 17:43:28 2002
+++ ./htparse.h Sun Oct 20 19:58:46 2002
@@ -70,6 +70,10 @@ extern char * HTParse PARAMS((
CONST char * relatedName,
int wanted));
+extern char * HTParseAnchor PARAMS(( /* fast HTParse() specialization */
+ CONST char * aName));
+
+
/* Simplify a filename. HTSimplify()
** --------------------
**
diff -u -p old/htparse.c ./htparse.c
--- old/htparse.c Sun Oct 6 17:43:28 2002
+++ ./htparse.c Sun Oct 20 19:58:16 2002
@@ -131,7 +133,8 @@ PRIVATE void scan ARGS2(
/*
** Check schemes that commonly have unescaped hashes.
*/
- if (parts->access && parts->anchor) {
+ if (parts->access && parts->anchor &&
+ /* optimize */ strchr("lnsdLNSD", *parts->access) != NULL) {
if ((!parts->host && strcasecomp(parts->access, "lynxcgi")) ||
!strcasecomp(parts->access, "nntp") ||
!strcasecomp(parts->access, "snews") ||
@@ -456,6 +459,30 @@ PUBLIC char * HTParse ARGS3(
return return_value; /* exactly the right length */
}
+
+
+PUBLIC char * HTParseAnchor ARGS1( /* fast HTParse() specialization */
+ CONST char *, aName)
+{
+ if (!aName)
+ return 0;
+
+ if (!strncasecomp(aName, "http://", 7) ||
+ !strncasecomp(aName, "file://", 7) ||
+ !strncasecomp(aName, "https://", 8)) { /* fast way */
+ char * p;
+ for (p = aName; *p && *p != '#'; p++)
+ ;
+ if (*p++) {
+ char * res = 0;
+ StrAllocCopy(res, p);
+ return res;
+ }
+ return 0;
+ }
+ return HTParse(aName, "", PARSE_ANCHOR); /* may have unescaped hashes */
+}
+
/* Simplify a filename. HTSimplify()
** --------------------
; To UNSUBSCRIBE: Send "unsubscribe lynx-dev" to address@hidden