[uim-commit] r2343 - branches/r5rs/sigscheme

yamaken at freedesktop.org yamaken at freedesktop.org
Sat Dec 3 14:03:24 PST 2005


Author: yamaken
Date: 2005-12-03 14:03:19 -0800 (Sat, 03 Dec 2005)
New Revision: 2343

Modified:
   branches/r5rs/sigscheme/read.c
Log:
* sigscheme/read.c
  - (read_sexpression): Optimize by case label reordering. No logic is
    changed


Modified: branches/r5rs/sigscheme/read.c
===================================================================
--- branches/r5rs/sigscheme/read.c	2005-12-03 21:46:38 UTC (rev 2342)
+++ branches/r5rs/sigscheme/read.c	2005-12-03 22:03:19 UTC (rev 2343)
@@ -187,6 +187,7 @@
 
         CDBG((SCM_DBG_PARSER, "read_sexpression c = %c", c));
 
+        /* case labels are ordered by appearance rate and penalty cost */
         switch (c) {
         case '(':
             DISCARD_LOOKAHEAD(port);
@@ -196,35 +197,10 @@
             DISCARD_LOOKAHEAD(port);
             return read_string(port);
 
-        case '0': case '1': case '2': case '3': case '4':
-        case '5': case '6': case '7': case '8': case '9':
-        case '+': case '-': case '.': case '@':
-            return read_number_or_symbol(port);
-
         case '\'':
             DISCARD_LOOKAHEAD(port);
             return read_quote(port, SYM_QUOTE);
 
-        case '`':
-            DISCARD_LOOKAHEAD(port);
-            return read_quote(port, SYM_QUASIQUOTE);
-
-        case ',':
-            DISCARD_LOOKAHEAD(port);
-            c = SCM_PORT_PEEK_CHAR(port);
-            switch (c) {
-            case EOF:
-                ERR("EOF in unquote");
-                /* NOTREACHED */
-
-            case '@':
-                DISCARD_LOOKAHEAD(port);
-                return read_quote(port, SYM_UNQUOTE_SPLICING);
-
-            default:
-                return read_quote(port, SYM_UNQUOTE);
-            }
-
         case '#':
             DISCARD_LOOKAHEAD(port);
             c = SCM_PORT_GET_CHAR(port);
@@ -246,6 +222,32 @@
             }
             break;
 
+        case '`':
+            DISCARD_LOOKAHEAD(port);
+            return read_quote(port, SYM_QUASIQUOTE);
+
+        case ',':
+            DISCARD_LOOKAHEAD(port);
+            c = SCM_PORT_PEEK_CHAR(port);
+            switch (c) {
+            case EOF:
+                ERR("EOF in unquote");
+                /* NOTREACHED */
+
+            case '@':
+                DISCARD_LOOKAHEAD(port);
+                return read_quote(port, SYM_UNQUOTE_SPLICING);
+
+            default:
+                return read_quote(port, SYM_UNQUOTE);
+            }
+
+        case '.': case '+': case '-':
+        case '1': case '2': case '3': case '4': case '5':
+        case '6': case '7': case '8': case '9': case '0':
+        case '@':
+            return read_number_or_symbol(port);
+
         case ')':
             ERR("invalid close parenthesis");
             /* NOTREACHED */



More information about the uim-commit mailing list