[ragel-users] optimization idea

Adrian Thurston thurs... at cs.queensu.ca
Wed Feb 27 22:14:56 UTC 2008


With optimizations turned on I believe that gcc uses a jump table. For large switches this is faster than binary searching. I would expect other compilers to do the same.

Try gcc --save-temps and have a look at the output.

-Adrian
-----Original Message-----
From: "Gaspard Bucher" <gaspard at teti.ch>

Date: Wed, 27 Feb 2008 10:32:53 
To:ragel-users at googlegroups.com
Subject: [ragel-users] optimization idea



When there is a bug regex, we end up with huge switch statements. From
what I understand from these statements, in the worst case, the
process must execute every instruction of type (jump not equal).

We could reduce this by implementing a simple binary tree when the
case statements get too big:

if (cs < 500) {
  if (cs < 250) {
    ...
   } else {
    ...
   }
} else {
  if (cs < 750) {
    ...
  } else {
    ...
  }
}

Is this stupid ?

Gaspard





More information about the ragel-users mailing list