On 06/25/2008 03:57 AM, Ulf Zibis wrote:
Hi David,

can you show an example using a 'switch' statement which is shorter or faster than:

char c = c2bMap.charAt(c2bMapIndex[(current & MASK1) >> SHIFT] + (current & MASK2));

Faster - maybe or maybe not; but the "c2bMap", being sparse, can be represented possibly more space-efficiently using a lookupswitch (I'm thinking of all the \u0000 entries, which can be handled with a "default" branch):

    public static final c2bMapper(int idx) {
        switch (idx) {
            case 1: return 1;
            case 2: return 2;
            ...
            default: return 0;
        }
    }

The primary disadvantage being, I guess, that the table cannot then be stored in e.g. a properties file.

- DML

Reply via email to