Closed genotrance closed 7 years ago
The problem is in nre.findIter which keeps on searching when it's never matched until it reaches the end of the input. The function keeps incrementing the offset by one and searches again until len of input is reached. This can take a long time when the input is large and can give the impression that the function hangs. The fix is simple: bail early when never matched instead of searching for the next match boundary.
I just tried it out your change and it works great - in fact it probably greatly speeds up the search performance since searching in large files and strings was going through each offset.
Hope it gets accepted into the main branch soon.
Short code example that hangs Nim:-
On pressing CTRL-C, following stack is printed:-
Replace URL with google.com and it works fine, try cnn.com, it hangs again. Not sure what about the content is confusing Nim or PCRE.