Ops, I will be affected as well. In my case I will have lots of non consecutive
enums hence it will be even slower.
**@Araq**, would you accept the fix with fields() and fieldPairs() magic
iterators to start working on enums. I think it makes a lot of sense for
non-ordinal enums to be able to iterate ids directly, not only low(T)..high(T)
hitting lots of values that do not belong to the enum.
fields() # will iterate ints
fieldPairs() # will iterate (string, int)
The parseEnum implementation will become
proc parseEnum*[T: enum](s: string): T =
## Parses an enum ``T``.
##
## Raises ``ValueError`` for an invalid value in `s`. The comparison is
## done in a style insensitive way.
let s: T
for name, id in fieldPairs(s):
if cmpIgnoreStyle(s, name) == 0:
return id
raise newException(ValueError, "invalid enum value: " & s)
and no string allocations.