diff options
author | Hiltjo Posthuma <hiltjo@codemadness.org> | 2016-03-04 21:10:40 +0100 |
---|---|---|
committer | Hiltjo Posthuma <hiltjo@codemadness.org> | 2016-03-04 21:10:40 +0100 |
commit | 673650f8f1bb6d8a7f9df30f06b5b34d6ca80ea5 (patch) | |
tree | 012b8d73c4de8a241bcf7f126e08085c4035156e | |
parent | f47a0d9ea0a5392417ae463634129354e28092d4 (diff) |
remove optimization with no effect, makes the code cleaner
-rw-r--r-- | sfeed.c | 19 |
1 files changed, 8 insertions, 11 deletions
@@ -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); } |