http://codereview.appspot.com/193077/diff/1001/12 File lily/general-scheme.cc (right):
http://codereview.appspot.com/193077/diff/1001/12#newcode230 lily/general-scheme.cc:230: return ((c >= 0x2D && c <= 0x2F) // hyphen, full-stop, and forward-slash On 2010/01/25 06:38:18, lemzwerg wrote:
Wouldn't it be faster to use an array of `0' and `1', indexed by the
character
code, instead of the many comparison operations? E.g.
escape_character[128] = { 0, 0, 0, ..., 1, 1, 0, ... }
Why not let the compiler bother about this? Note that with current computer architectures, a random memory access can easily take 10 times or more than a comparison. But I think that gcc is a compilation requirement anyway, so it would just do to write: switch (c) { case '-': case '.': case '/': case '0'...'9': case 'A'...'Z': case '_': case 'a'...'z': return 1; } return 0; This saves having to write any comment since the code is clear enough on its own, and the compiler has all the info it needs to generate more concise code than a human could. In particular since the optimal code may well depend on the target architecture. http://codereview.appspot.com/193077/show _______________________________________________ lilypond-devel mailing list lilypond-devel@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-devel