From 673650f8f1bb6d8a7f9df30f06b5b34d6ca80ea5 Mon Sep 17 00:00:00 2001 From: Hiltjo Posthuma Date: Fri, 4 Mar 2016 21:10:40 +0100 Subject: remove optimization with no effect, makes the code cleaner --- sfeed.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/sfeed.c b/sfeed.c index 553062f..de21b2c 100644 --- 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 inside tag * or any other non- 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); } -- cgit v1.2.3