mssola / user_agent

This project has been moved, check the README.md file!

Home Page:https://github.com/mssola/useragent

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Precompile regex

dim opened this issue · comments

Instead of compiling the regular expressions on each cycle, you should precompile them for improved performance, i.e.:

Instead of:

reg, _ := regexp.Compile("^rv:(.+)$")

You should declare a global and reusable:

var rvReg = regexp.MustCompile("^rv:(.+)$")

@dim Thanks for the suggestion :)