Hi, I'm trying to optimize my CSV parser class, and facing with a bit unexpected results. I tried to change in-place set declaration (if ch in [a, b, c] then ...) to reusable set constants (if ch in ABCSet then ...), and noticed a slight slowdown. To check it, I created a simple test application:
const cs: set of char = ['a', 'b', 'c', 'd', 'e']; var i: Integer; c: Char; b: Boolean; begin c := 'a'; for i := 0 to MaxInt do begin // A. In-place set declaration b := c in ['a', 'b', 'c', 'd', 'e']; // B. Set constant // b := c in cs; end; end. I was surprised when B turned out to be almost 3 times slower than A (~11 vs ~29 sec. on my hardware). This ratio remains nearly the same regardless of compiler optimization level. I'm using FPC 2.4.2 [2010/12/27] for i386 on Linux. 1) Is it expected behavior, or should I create a bug report about it? 2) What way (A or B) are you using in your programs (or would suggest to use in long term)? Thanks in advance. -- Vladimir _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal