08.01.2017 17:11, Grazvydas Ignotas пишет:
On Sat, Jan 7, 2017 at 9:02 PM, Vladislav Egorov <vegorov...@gmail.com> wrote:
@@ -582,6 +609,333 @@ HEXADECIMAL_INTEGER       0[xX][0-9a-fA-F]+[uU]?

  %%

+static void
+glcpp_fast_skip_singleline_comment (glcpp_parser_t *parser, char **input)
+{
+   /* Skip // */
+   char *buf = *input + 2;
+
+   while (true) {
+      char ch = *buf;
+      if (ch == '\r' || ch == '\n' || ch == '\0')
+         break;
+      buf++;
+   }
Looks like strpbrk() could be used here too?
Also null char handling looks suspicious.

Gražvydas
strpbrk() returns NULL if it encountered '\0', not '\0's position. It seems that strcspn() is needed here. On my system GCC inlines it and generates more or less the same code as loop/if variant, without significant change in profiler, so it probably will be fine.
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to