java - Eclipse 如何对短语/正则表达式的命中执行如此快速的搜索

标签 java regex eclipse search

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 使用了 数据库引擎。

然后,如果你再深入一点,这里有一个 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/

相关文章:

regex - 如何将名字拆分为姓氏和首字母

java - 将正则表达式与数组进行匹配

mysql - 如何在mysql中匹配一个ip地址?

java - 泛型和 compareTo() 方法

java - 将项目导入 Eclipse 但不导入工作区文件夹

java - 不可变的@ConfigurationProperties

java - 为什么我的 Java for 循环不会在循环外设置变量?

java - 使用 for 循环填充数组时遇到问题 - java

java - Grouplayout 中的复选框超出行范围

java - 寻找空指针异常的原因