Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
尝试从以下两个方面提高性能。
1
self::$trie
命中的词组,无需再做一次end相关的比较。2
self::$trie
未命中的词组,若多次出现,则第二次开始,无需再去调用MultiArray::get
并最终用MultiArray::getValue
进行递归遍历。因为是跟self::$trie相关,所以在self::$trie作修改的时候需要清除缓存。
我用如下代码在浏览器中进行测试,跟之前对比,大概能有百分之二十左右的提升。像"是否和"一词在lyric.txt.中出现了8次,对它的处理就会比之前更快。
不知对 #27 会不会有所帮助。