You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note 2 / Question: for perf reason, we want to compile regexp and cache them. Thus we need a caching solution. Options:
Direct use sync.Map and a simple helper function to load/compile regexp. Pro: simple, no external dependency; Con, at risk of unbounded cache growth, should we have a use case where regexp variety/cardinality is huge.
Use some LRU cache with fixed capacity such as github.com/hashicorp/golang-lru. Pro: bounded cache size Con: external dependency; slightly slower than sync.Map.
@zhengchun have a second thought - your xpath currently has zero external dep (other than go SDK). Intro a 3rd party dep complicates your compatibility story - xpath runs on go 1.6, 1.9 and 1.10 (which are fairly ancient) and not compatible with most LRU libs. I think I will stick with use built-in constructs (map or sync.Map) with a simple reset if cap is reached. We will see. PR will come tomorrow.
On a third thought ^_^, seems like no need to support flags, anyone wants to use flags can directly implement the flags in the pattern argument, such as (?i) for flag i, (?s) for flag s.
See
matches
spec at: https://www.w3.org/TR/xpath-functions-31/#func-matchesNote 1: https://www.w3.org/TR/xpath-functions-31/#flags shows all the supported flags, but will only implement flags
's'
,'m'
,'i'
and'q'
. Will not include'x'
due to lack of native support in https://golang.org/pkg/regexp/syntax/.Note 2 / Question: for perf reason, we want to compile regexp and cache them. Thus we need a caching solution. Options:
sync.Map
and a simple helper function to load/compile regexp.Pro: simple, no external dependency;
Con, at risk of unbounded cache growth, should we have a use case where regexp variety/cardinality is huge.
Pro: bounded cache size
Con: external dependency; slightly slower than
sync.Map
.@zhengchun What do you think?
The text was updated successfully, but these errors were encountered: