Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fast text editor find

Does anyone know how text editors/programmers editors are able to do such fast searches on very large text files.

Are they indexing on load, at the start of the find or some other clever technique?

I desperately need a faster implementation of what I have which is a desperately slow walk from top to bottom of the text.

Any ideas are really appreciated.

This is for a C# implementation, but its the technique I'm interested in more than the actual code.

like image 618
Andy Avatar asked Feb 10 '09 09:02

Andy


2 Answers

Begin with Boyer-Moore search algorithm. It requires some preprocessing (which is fast) and does searching pretty well - especially when searching for long substrings.

like image 52
Anton Gogolev Avatar answered Sep 21 '22 15:09

Anton Gogolev


I wouldn't be surprised if most just use the basic, naive search technique (scan for a match on the 1st char, then test if the hit pans out).

  • The cost of trying too hard: String searching
  • Eric Lippert's comment in the above blog post
like image 23
Michael Burr Avatar answered Sep 17 '22 15:09

Michael Burr