sfeed

simple feed reader - forked from git.codemadness.org/sfeed
git clone git://src.gearsix.net/sfeed
Log | Files | Refs | Atom | README | LICENSE

commit 673650f8f1bb6d8a7f9df30f06b5b34d6ca80ea5
parent f47a0d9ea0a5392417ae463634129354e28092d4
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Fri,  4 Mar 2016 21:10:40 +0100

remove optimization with no effect, makes the code cleaner

Diffstat:
Msfeed.c | 19++++++++-----------
1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/sfeed.c b/sfeed.c @@ -173,7 +173,7 @@ gettag(enum FeedType feedtype, const char *name, size_t namelen) { NULL, 0, -1 } }; const FeedTag *tags; - int i, n; + int i; /* optimization: these are always non-matching */ if (namelen < 2 || namelen > 17) @@ -184,15 +184,12 @@ gettag(enum FeedType feedtype, const char *name, size_t namelen) case FeedTypeAtom: tags = &atomtags[0]; break; default: return TagUnknown; } - /* search */ - for (i = 0; tags[i].name; i++) { - if (!(n = strcasecmp(tags[i].name, name))) - return tags[i].id; /* found */ - /* optimization: tags are sorted so nothing after matches. */ - if (n > 0) - return TagUnknown; - } - return TagUnknown; /* NOTREACHED */ + + for (i = 0; tags[i].name; i++) + if (istag(tags[i].name, tags[i].len, name, namelen)) + return tags[i].id; + + return TagUnknown; } /* Clear string only; don't free, prevents unnecessary reallocation. */ @@ -563,7 +560,7 @@ xml_handler_data(XMLParser *p, const char *s, size_t len) /* add only data from <name> inside <author> tag * or any other non-<author> tag */ - if (ctx.tagid != AtomTagAuthor || !strcasecmp(p->tag, "name")) + if (ctx.tagid != AtomTagAuthor || istag(p->tag, p->taglen, "name", 4)) string_append(ctx.field, s, len); }