Eclipse 在一个大型项目中搜索与一个短语(甚至是正则表达式短语)的所有匹配项的速度惊人地快。
他们在内部使用 java.util.regex
吗?
我假设他们没有使用搜索引擎编制索引,因为他们的搜索速度太慢了,但是在启动 eclipse 后第一次搜索时会有一些延迟。
最佳答案
Eclipse Helios (3.6) includes an improved version of Eclipse PDT, labeled 2.2. It is also included in the current Zend Studio (7.1 and above). Among other enhancements, it dramatically improved the performance of code lookup-related tasks like searching references, creating a type hierarchy and even code completion. This is due to a new design, inspired by nWire, which uses the h2 database engine as a persistent storage for this data.
The h2 database is a high-performance, low profile, Java native database engine, created as a successor to the widely used HSQLDB. It is open source and free to use. nWire uses h2 since its' early days.
Source: http://www.nwiresoftware.com/blogs/nwire/2010/09/five-tips-speeding-eclipse-pdt-and-nwire
简而言之,您似乎看到了这些改进,因为 Eclipse 使用了 h2数据库引擎。
然后,如果你再深入一点,这里有一个 quick sampling if the H2 source code ;看起来他们确实在利用 java.util.regex
:
20 import java.util.regex.Matcher;
21 import java.util.regex.Pattern;
关于java - Eclipse 如何对短语/正则表达式的命中执行如此快速的搜索,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12233466/