> This depends entirely on your app's requirements. What, exactly, are
> your regexes doing? Can it be done more simply?
They are evaluating a given string for a match, so that finally a
function can return which classification this string is in.
Something along the lines of:
if(incoming string matches any of {X1} set of regexpes)
return "Value1"
if(incoming string matches any of {x2} set of regexps)
return "Value2"
...
there are about three or four possible values, but the regexps must
cover about 100000 different cases of "incoming string".
> -- You may be better off using arrays of char, or one giant array of
> char containing all strings, than the String class. String creates a lot
> of garbage.
The strings are a restriction that I cannot remove :)
I'm thinking of making an index with the 100000 Strings.
> -- Make sure you compile your regexes in advance. Don't recompile before
> each comparison.
It's already done this way.
> -- Depending on your app, you might be able to use a lexer instead. See
> http://www.jflex.de/. There's a learning curve, but it's *really* fast.
Will check it out, thank you!
JGN
Oliver Wong - 07 Aug 2006 19:57 GMT
>> This depends entirely on your app's requirements. What, exactly, are
>> your regexes doing? Can it be done more simply?
[quoted text clipped - 12 lines]
> there are about three or four possible values, but the regexps must
> cover about 100000 different cases of "incoming string".
Please give examples of:
(*) The incoming strings.
(*) The regular expressions.
(*) The values returned.
Otherwise, I can only offer the vague advice "look at decision trees".
- Oliver
>> Hi,
>>
[quoted text clipped - 27 lines]
> -- Depending on your app, you might be able to use a lexer instead. See
> http://www.jflex.de/. There's a learning curve, but it's *really* fast.
-- Optimize the RX.
-- Preprocess and cache results (do those strings change? if yes and
there's repetition some form of LRU cache might help)
We certainly have too few information to narrow it down.
robert