Skip to content

Make regex matching stable and optimize brand name and device type lookups#6

Open
WingGithub wants to merge 2 commits into
slipros:masterfrom
WingGithub:bugfix/sort-devicereg-arrays
Open

Make regex matching stable and optimize brand name and device type lookups#6
WingGithub wants to merge 2 commits into
slipros:masterfrom
WingGithub:bugfix/sort-devicereg-arrays

Conversation

@WingGithub

Copy link
Copy Markdown

An user agent like "Roku/DVP-14.0 (14.0.0.6047-30)" can potentially match either the regex for "Roku" or "Unknown" in a random manner because the order of iterating a golang map of regex values is non deterministic unlike a PHP array which is sorted. We want the user agent to alway match the regex for "Roku" first before matching the catch all regex for "Unknown".

The device type and brand name lookups are iterating through a map in a loop instead of using map lookups directly which is the correct way to use maps. For reverse lookups, we can create a reverse lookup maps which will also optimize lookup speed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant