Index: glib/gscanner.c
===================================================================
--- glib/gscanner.c	(revision 5377)
+++ glib/gscanner.c	(working copy)
@@ -168,6 +168,25 @@
   return -1;
 }
 
+static gboolean*
+g_scanner_cset_2_table (guchar*	cset)
+{
+  gboolean* table = g_new0(gboolean, 256);
+  while (*cset)
+    {
+    	table[*cset] = TRUE;
+	cset++;
+    }
+ return table;
+}
+
+static inline gboolean
+g_scanner_cset_table_lookup (gboolean* table, guint c)
+{
+  if (c>=256) return FALSE;
+  return table[c];
+}
+
 GScanner*
 g_scanner_new (const GScannerConfig *config_templ)
 {
@@ -234,6 +253,11 @@
   
   scanner->msg_handler = g_scanner_msg_handler;
   
+  scanner->cset_identifier_first_table = g_scanner_cset_2_table((guchar*)scanner->config->cset_identifier_first);
+  scanner->cset_identifier_nth_table = g_scanner_cset_2_table((guchar*)scanner->config->cset_identifier_nth);
+  scanner->cset_skip_characters_table = g_scanner_cset_2_table((guchar*)scanner->config->cset_skip_characters);
+  
+  
   return scanner;
 }
 
@@ -282,6 +306,9 @@
   g_scanner_free_value (&scanner->next_token, &scanner->next_value);
   g_free (scanner->config);
   g_free (scanner->buffer);
+  g_free (scanner->cset_identifier_first_table);
+  g_free (scanner->cset_identifier_nth_table);
+  g_free (scanner->cset_skip_characters_table);
   g_free (scanner);
 }
 
@@ -865,8 +892,8 @@
       if (scanner->token >= 1 && scanner->token <= 255)
 	{
 	  if ((scanner->token >= ' ' && scanner->token <= '~') ||
-	      strchr (scanner->config->cset_identifier_first, scanner->token) ||
-	      strchr (scanner->config->cset_identifier_nth, scanner->token))
+	      g_scanner_cset_table_lookup (scanner->cset_identifier_first_table, scanner->token) ||
+	      g_scanner_cset_table_lookup (scanner->cset_identifier_nth_table, scanner->token))
 	    _g_snprintf (token_string, token_string_len, "character `%c'", scanner->token);
 	  else
 	    _g_snprintf (token_string, token_string_len, "character `\\%o'", scanner->token);
@@ -1010,8 +1037,8 @@
       if (expected_token >= 1 && expected_token <= 255)
 	{
 	  if ((expected_token >= ' ' && expected_token <= '~') ||
-	      strchr (scanner->config->cset_identifier_first, expected_token) ||
-	      strchr (scanner->config->cset_identifier_nth, expected_token))
+	      g_scanner_cset_table_lookup (scanner->cset_identifier_first_table, expected_token) ||
+	      g_scanner_cset_table_lookup (scanner->cset_identifier_nth_table, expected_token))
 	    _g_snprintf (expected_string, expected_string_len, "character `%c'", expected_token);
 	  else
 	    _g_snprintf (expected_string, expected_string_len, "character `\\%o'", expected_token);
@@ -1160,9 +1187,9 @@
       g_scanner_get_token_ll (scanner, token_p, value_p, line_p, position_p);
     }
   while (((*token_p > 0 && *token_p < 256) &&
-	  strchr (scanner->config->cset_skip_characters, *token_p)) ||
+	  g_scanner_cset_table_lookup (scanner->cset_skip_characters_table, *token_p)) ||
 	 (*token_p == G_TOKEN_CHAR &&
-	  strchr (scanner->config->cset_skip_characters, value_p->v_char)) ||
+	  g_scanner_cset_table_lookup (scanner->cset_skip_characters_table, value_p->v_char)) ||
 	 (*token_p == G_TOKEN_COMMENT_MULTI &&
 	  scanner->config->skip_comment_multi) ||
 	 (*token_p == G_TOKEN_COMMENT_SINGLE &&
@@ -1258,7 +1285,7 @@
        * might interfere with other key chars like slashes or numbers
        */
       if (config->scan_identifier &&
-	  ch && strchr (config->cset_identifier_first, ch))
+	  ch && g_scanner_cset_table_lookup (scanner->cset_identifier_first_table, ch))
 	goto identifier_precedence;
       
       switch (ch)
@@ -1641,12 +1668,12 @@
 		in_comment_single = FALSE;
 	    }
 	  else if (config->scan_identifier && ch &&
-		   strchr (config->cset_identifier_first, ch))
+		   g_scanner_cset_table_lookup (scanner->cset_identifier_first_table, ch))
 	    {
 	    identifier_precedence:
 	      
 	      if (config->cset_identifier_nth && ch &&
-		  strchr (config->cset_identifier_nth,
+		  g_scanner_cset_table_lookup (scanner->cset_identifier_nth_table,
 			  g_scanner_peek_next_char (scanner)))
 		{
 		  token = G_TOKEN_IDENTIFIER;
@@ -1658,7 +1685,7 @@
 		      gstring = g_string_append_c (gstring, ch);
 		      ch = g_scanner_peek_next_char (scanner);
 		    }
-		  while (ch && strchr (config->cset_identifier_nth, ch));
+		  while (ch && g_scanner_cset_table_lookup (scanner->cset_identifier_nth_table, ch));
 		  ch = 0;
 		}
 	      else if (config->scan_identifier_1char)
Index: glib/gscanner.h
===================================================================
--- glib/gscanner.h	(revision 5377)
+++ glib/gscanner.h	(working copy)
@@ -197,7 +197,9 @@
   const gchar		*text_end;
   gchar			*buffer;
   guint			scope_id;
-  
+  gboolean		*cset_identifier_first_table;
+  gboolean		*cset_identifier_nth_table;
+  gboolean		*cset_skip_characters_table;
   /* handler function for _warn and _error */
   GScannerMsgFunc	msg_handler;
 };
