lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fix #887: Use ly:string-percent-encode for textedit URIs. (issue193


From: dak
Subject: Re: Fix #887: Use ly:string-percent-encode for textedit URIs. (issue193077)
Date: Mon, 25 Jan 2010 09:28:36 +0000


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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]