[PATCH 2/2] string: vectorize strspn single-accept-char case

Wilco Dijkstra <[email protected]>
Newsgroups gmane.comp.lib.glibc.alpha
Message-ID <PAWPR08MB8982CC9CBDF5C005EF1A93C383DB2@PAWPR08MB8982.eurprd08.prod.outlook.com>
Hi Matt,

+      do
+	{
+	  word = *++word_ptr;
+	  mask = find_ne_all (word, repeated_c);
+	}
+      while (mask == 0);
+
+      return (const char *) word_ptr - str + index_first (mask);

And this should obviously be:

do
  {
    word = *++word_ptr;
  }
while (word == repeated_c);

return (const char *) word_ptr - str + index_first (find_ne_all (word, repeated_c));

That makes the loop several times faster.

Whether it is worth optimizing this at all is another question - are people actually
using single-char strspn for performance critical things? Scanners certainly don't,
so the most likely scenario might be skipping repeated slashes in path names...

Cheers,
Wilco
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.