pongo2 icon indicating copy to clipboard operation
pongo2 copied to clipboard

Optimize context valid identifier check

Open Richtermeister opened this issue 2 years ago • 1 comments

This might seem like a micro-optimization, but we are using this library in a tight loop with a large input map, and the regex usage is adding up. This PR contains a commit with the benchmark used.

goos: linux
goarch: amd64
pkg: github.com/flosch/pongo2/v6
cpu: Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
BenchmarkCheckForValidIdentifiers/regex-8         	 5310591	       231.0 ns/op	       0 B/op	       0 allocs/op
BenchmarkCheckForValidIdentifiers/char_check-8    	127916318	         9.171 ns/op	       0 B/op	       0 allocs/op

Richtermeister avatar Dec 12 '23 02:12 Richtermeister

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

sonarqubecloud[bot] avatar Dec 12 '23 02:12 sonarqubecloud[bot]