I am making an html parser and it is coming out great. I can get tags their classes and id's. Its also really simple to get all other attributes.
The issue is that it is rather slow and I am struggling to make it faster. I have tried removing things that aren't as necessary including more If statements to reduce the need to check other code. I did some research and found out that find() in C++ is rather slow for larger strings. I have done test using websites like example.com and parsed it. It takes 3 seconds which is pretty slow but somewhat bearable then I tried more complex sites and it takes about 8 minutes which is ridiculous. This is the first time I do something like this.
Is there a way to find a substring within a string much faster than using .find()?
I know that there is definitely more I can do like reducing amount of allocations which I am looking to do but if you have any suggestions it would be greatly appreciated!
Example
std::string test = "A string that has half a million characters!";
std::cout << test.find("half") << std::endl;