The best answer depends quite a bit on how many haystacks you have and the minimum size of a needle. Therefore, there's a good chance you can do better for your particular problem. The existence of a recursive/non-recursive distinction is a pretty strong suggestion that BOOST is not necessarily a linear-time discrete finite-state machine. Then reading x next will move me to the string 1 matched state etc., and any char other than xyz will move to the initial state, and I will not need to retract back to b. Not that I can program better than the boost guys, but perhaps a dedicated implementation is more efficient than a general one.Īs the strings stay constant over long time, I can afford building a data structure, like a state transition table, upfront.Į.g., if the strings are abcx, bcy and cz, and I've read so far abc, I should be in a combined state that means you're either 3 chars into string 1, 2 chars into string 2 or 1 char into string 1. The performance of this task is important, so I wonder if I can improve it. I am currently using boost regex matching with str1 | str2 |. Additional simplification is that none of the strings is contained in any other. The strings are constant for the whole session and are not many (~10). I need to search incoming not-very-long pieces of text for occurrences of given strings.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |