TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Show HN: K(r)ep - A high-performance string search utility

21 pointsby daviducoloabout 2 months ago

4 comments

aw1621107about 2 months ago
Posted here about a month ago: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=43333946">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=43333946</a>
评论 #43708365 未加载
alkhabout 2 months ago
The fact that even in the test example it took ripgrep 0.115 s with 97% CPU usage vs Krep&#x27;s 0.106 s with 328% CPU usage is a testament of why ripgrep is still preferable. Such a huge tradeoff in resource consumption for such a small speed gain is hard to justify
评论 #43707812 未加载
MattPalmer1086about 2 months ago
There&#x27;s a few issues with the Horspool implementation.<p>To obtain non case sensitive searching, you set the shift in the bad char table for both the upper and lower case variants. That&#x27;s fine. But when you come to do the search, you ignore this and only look up the lower case version if it&#x27;s non case sensitive. This is unnecessary - the valid shifts for both cases are already in the table, since you put them there. So you can avoid doing a lookup on the lower table.<p>I think you also only ever shift by one if you get a full match, but this is also unnecessary. You can shift by whatever the last char bad char shift is and you won&#x27;t miss any patterns, even if they can overlap.<p>Finally, you have a test to see if the shift is zero, and to set it to one if it is. You should never get a shift of zero from the bad char table (you don&#x27;t process the last char of the pattern when creating the bad char table, so there is never a distance of zero from the end).
评论 #43713416 未加载
daviducoloabout 2 months ago
I have just released version 1.1.0 which should fix the problems reported by users.<p><a href="https:&#x2F;&#x2F;github.com&#x2F;davidesantangelo&#x2F;krep&#x2F;releases&#x2F;tag&#x2F;v1.1.0">https:&#x2F;&#x2F;github.com&#x2F;davidesantangelo&#x2F;krep&#x2F;releases&#x2F;tag&#x2F;v1.1.0</a>