golang/go

regexp: Scan the input string backward for patterns ending in $

Open

#21,743 建立於 2017年9月2日

在 GitHub 查看
 (4 留言) (1 反應) (0 負責人)Go (19,008 fork)batch import
NeedsFixPerformancehelp wanted

倉庫指標

Star
 (133,883 star)
PR 合併指標
 (30 天內沒有已合併 PR)

描述

As suggested by @rsc:

It seems clear that we should handle patterns ending in $, like \.(jpe?g|gif)$, by scanning the string backward, which cuts the processing from O(n) to O(1) for an input of size n. That's easy to add to the existing matchers and doesn't need to be limited to fixed-size patterns.

I'm working on a CL to implement it for strings and byte slices.

貢獻者指南