René's URL Explorer Experiment


Title: cppcheckdata.py: compile `match()` patterns once by pfultz2 · Pull Request #8999 · cppcheck-opensource/cppcheck · GitHub

Open Graph Title: cppcheckdata.py: compile `match()` patterns once by pfultz2 · Pull Request #8999 · cppcheck-opensource/cppcheck

X Title: cppcheckdata.py: compile `match()` patterns once by pfultz2 · Pull Request #8999 · cppcheck-opensource/cppcheck

Description: cppcheckdata.match() re-parsed its pattern string on every call: it split the pattern, split off the @ bindings, and match_atom() ran through a chain of in/startswith checks for each word before doing the actual comparison. On a failed match it also rebuilt the list of binding keys and allocated a new MatchResult. Since an addon typically matches the same handful of pattern strings against every token, almost all of this work was repeated. This PR adds a CompiledPattern class that compiles a pattern string once into a list of per-word matcher functions, plus a precomputed MatchResult for the failed case. match(token, pattern) keeps its signature and looks the compiled pattern up in a cache keyed by the pattern string. The internal match_atom() helper is removed; its logic is now CompiledPattern.compile_atom(). Two behavior changes, both for degenerate patterns: A whitespace-only pattern used to report a successful match (with end = None). It now fails, the same as an empty pattern. |= is now a literal word. Previously the | in it was also read as an alternation of '' and =, so the pattern |= matched a = token as well. (The C++ Token::Match still has that quirk; the Python side no longer shares it.) Performance Measured on the first configuration of a lib/token.cpp dump (49,349 tokens), Python 3. 12 patterns (if (*) {, %name% (*) ;, %var%@lhs = %var%@op1 | %var%@op2 ;, struct|class %name% {, %name% !!(, for (*) {*}, %comp%, ::, …) matched against every token, ~592k calls: before after speedup total time 0.78 s 0.21 s ~3.7× per call ~1.3 µs ~0.36 µs 200,000 calls of match(tok, '%name% (*) ;') on one token (per-call overhead, no matching work): before after speedup total time 0.23 s 0.04 s ~5.5× One-time compile cost per distinct pattern (not cached per word; happens once per pattern string): pattern compile if (*) { 1.6 µs %var%@lhs = %var%@op1 | %var%@op2 ; 2.3 µs struct|class %name% { 2.0 µs **{ 1.3 µs

Open Graph Description: cppcheckdata.match() re-parsed its pattern string on every call: it split the pattern, split off the @ bindings, and match_atom() ran through a chain of in/startswith checks for each word before do...

X Description: cppcheckdata.match() re-parsed its pattern string on every call: it split the pattern, split off the @ bindings, and match_atom() ran through a chain of in/startswith checks for each word before do...

Opengraph URL: https://github.com/cppcheck-opensource/cppcheck/pull/8999

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:6b5d0dc5-acc5-4351-5328-d0dfd220247e
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idCFBE:14BEEB:3A02A8:50AD87:6AFC5182
html-safe-nonce3e0ad257f3af4b6f4bb86433c0ca7732b23919fdb414826b16405db49c3b8a76
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRkJFOjE0QkVFQjozQTAyQTg6NTBBRDg3OjZBRkM1MTgyIiwidmlzaXRvcl9pZCI6IjM1OTcyMDQyNTY1OTY5NzE5MDYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac5b145a9392b30bee1e240937b82548a53c22524cd5fab51a3e5369f0cc1e4fd5
hovercard-subject-tagpull_request:5180443792
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/cppcheck-opensource/cppcheck/pull/8999/files
twitter:imagehttps://avatars.githubusercontent.com/u/1306044?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/1306044?s=400&v=4
og:image:altcppcheckdata.match() re-parsed its pattern string on every call: it split the pattern, split off the @ bindings, and match_atom() ran through a chain of in/startswith checks for each word before do...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Noneb63557e0027d8014589e873df28328da74a4356701bb1a9eab49dbf012ba8fa6
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/cppcheck-opensource/cppcheck git https://github.com/cppcheck-opensource/cppcheck.git
octolytics-dimension-user_id278097703
octolytics-dimension-user_logincppcheck-opensource
octolytics-dimension-repository_id143131
octolytics-dimension-repository_nwocppcheck-opensource/cppcheck
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id143131
octolytics-dimension-repository_network_root_nwocppcheck-opensource/cppcheck
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release0243355b0352c83733a042e0dfb3d75149b51261
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/cppcheck-opensource/cppcheck/pull/8999/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fcppcheck-opensource%2Fcppcheck%2Fpull%2F8999%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fcppcheck-opensource%2Fcppcheck%2Fpull%2F8999%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=cppcheck-opensource%2Fcppcheck
Reloadhttps://github.com/cppcheck-opensource/cppcheck/pull/8999/files
Reloadhttps://github.com/cppcheck-opensource/cppcheck/pull/8999/files
Reloadhttps://github.com/cppcheck-opensource/cppcheck/pull/8999/files
cppcheck-opensourcehttps://github.com/cppcheck-opensource
cppcheckhttps://github.com/cppcheck-opensource/cppcheck
Codehttps://github.com/cppcheck-opensource/cppcheck
Pull requests222 (222)https://github.com/cppcheck-opensource/cppcheck/pulls
Actionshttps://github.com/cppcheck-opensource/cppcheck/actions
Security and qualityhttps://github.com/cppcheck-opensource/cppcheck/security
Insightshttps://github.com/cppcheck-opensource/cppcheck/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fcppcheck-opensource%2Fcppcheck%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fcppcheck-opensource%2Fcppcheck%2Fissues%2Fnew%2Fchoose
pfultz2https://github.com/pfultz2
cppcheck-opensource:mainhttps://github.com/cppcheck-opensource/cppcheck/tree/main
pfultz2:addon-match-perfhttps://github.com/pfultz2/cppcheck/tree/addon-match-perf
Conversation 10 https://github.com/cppcheck-opensource/cppcheck/pull/8999
Commits 6 https://github.com/cppcheck-opensource/cppcheck/pull/8999/commits
Checks 71 https://github.com/cppcheck-opensource/cppcheck/pull/8999/checks
Files changed https://github.com/cppcheck-opensource/cppcheck/pull/8999/files
Please reload this pagehttps://github.com/cppcheck-opensource/cppcheck/pull/8999/files
cppcheckdata.py: compile match() patterns once https://github.com/cppcheck-opensource/cppcheck/pull/8999/files#top
Show all changes 6 commits https://github.com/cppcheck-opensource/cppcheck/pull/8999/files
e94d0cd Improve Match perf pfultz2 Nov 5, 2026 https://github.com/cppcheck-opensource/cppcheck/pull/8999/commits/e94d0cd9f229144cf7bd281142da2c2c1ca7137b
baf9f30 Add a CompiledPattern class pfultz2 Nov 5, 2026 https://github.com/cppcheck-opensource/cppcheck/pull/8999/commits/baf9f3074583f5b72d8ddf3fcbcf578b76092bff
b18f149 Remove atom cache pfultz2 Nov 5, 2026 https://github.com/cppcheck-opensource/cppcheck/pull/8999/commits/b18f1498d96af92ecb1ff710c648ab815acf982d
ec8567f Fix the quirk pfultz2 Nov 6, 2026 https://github.com/cppcheck-opensource/cppcheck/pull/8999/commits/ec8567f5f36558ca780ce89ff13b9e5dc957b1eb
c59f7f1 Fix the quirk for git diff|= pfultz2 Nov 6, 2026 https://github.com/cppcheck-opensource/cppcheck/pull/8999/commits/c59f7f16f958961fc117c6b9c221eb7aafd383a5
955b562 Restore the guard pfultz2 Nov 8, 2026 https://github.com/cppcheck-opensource/cppcheck/pull/8999/commits/955b562d351320e09f89534b636f674eb4034694
Clear filters https://github.com/cppcheck-opensource/cppcheck/pull/8999/files
Please reload this pagehttps://github.com/cppcheck-opensource/cppcheck/pull/8999/files
Please reload this pagehttps://github.com/cppcheck-opensource/cppcheck/pull/8999/files
cppcheckdata.py https://github.com/cppcheck-opensource/cppcheck/pull/8999/files#diff-a26c2945ff684061f9f5df6ff53fe187e89975c8f6b3c69419c596d6857d3583
conftest.py https://github.com/cppcheck-opensource/cppcheck/pull/8999/files#diff-23c90d8991a930c1a0d61b0735aec22986b102a5bae4c4161313a8ad1337ebd0
test_cppcheckdata.py https://github.com/cppcheck-opensource/cppcheck/pull/8999/files#diff-8e1ef950d717b15d0e188c070e1adc26e784f282c38f8cb193c4f9cc288d6c90
addons/cppcheckdata.pyhttps://github.com/cppcheck-opensource/cppcheck/pull/8999/files#diff-a26c2945ff684061f9f5df6ff53fe187e89975c8f6b3c69419c596d6857d3583
View file https://github.com/cppcheck-opensource/cppcheck/blob/955b562d351320e09f89534b636f674eb4034694/addons/cppcheckdata.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/cppcheck-opensource/cppcheck/pull/8999/{{ revealButtonHref }}
https://github.com/cppcheck-opensource/cppcheck/pull/8999/files#diff-a26c2945ff684061f9f5df6ff53fe187e89975c8f6b3c69419c596d6857d3583
https://github.com/cppcheck-opensource/cppcheck/pull/8999/files#diff-a26c2945ff684061f9f5df6ff53fe187e89975c8f6b3c69419c596d6857d3583
dmcppcheckhttps://github.com/dmcppcheck
Nov 6, 2026https://github.com/cppcheck-opensource/cppcheck/pull/8999/files#r4488585144
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/cppcheck-opensource/cppcheck/pull/8999/files
pfultz2https://github.com/pfultz2
Nov 6, 2026https://github.com/cppcheck-opensource/cppcheck/pull/8999/files#r4497854203
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/cppcheck-opensource/cppcheck/pull/8999/files
dmcppcheckhttps://github.com/dmcppcheck
Nov 8, 2026https://github.com/cppcheck-opensource/cppcheck/pull/8999/files#r4505107079
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/cppcheck-opensource/cppcheck/pull/8999/files
dmcppcheckhttps://github.com/dmcppcheck
Nov 8, 2026https://github.com/cppcheck-opensource/cppcheck/pull/8999/files#r4505107073
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/cppcheck-opensource/cppcheck/pull/8999/files
dmcppcheckhttps://github.com/dmcppcheck
Nov 7, 2026https://github.com/cppcheck-opensource/cppcheck/pull/8999/files#r4498911365
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/cppcheck-opensource/cppcheck/pull/8999/files
https://github.com/cppcheck-opensource/cppcheck/pull/8999/files#diff-a26c2945ff684061f9f5df6ff53fe187e89975c8f6b3c69419c596d6857d3583
test/addon/conftest.pyhttps://github.com/cppcheck-opensource/cppcheck/pull/8999/files#diff-23c90d8991a930c1a0d61b0735aec22986b102a5bae4c4161313a8ad1337ebd0
View file https://github.com/cppcheck-opensource/cppcheck/blob/955b562d351320e09f89534b636f674eb4034694/test/addon/conftest.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/cppcheck-opensource/cppcheck/pull/8999/{{ revealButtonHref }}
https://github.com/cppcheck-opensource/cppcheck/pull/8999/files#diff-23c90d8991a930c1a0d61b0735aec22986b102a5bae4c4161313a8ad1337ebd0
https://github.com/cppcheck-opensource/cppcheck/pull/8999/files#diff-23c90d8991a930c1a0d61b0735aec22986b102a5bae4c4161313a8ad1337ebd0
test/addon/test_cppcheckdata.pyhttps://github.com/cppcheck-opensource/cppcheck/pull/8999/files#diff-8e1ef950d717b15d0e188c070e1adc26e784f282c38f8cb193c4f9cc288d6c90
View file https://github.com/cppcheck-opensource/cppcheck/blob/955b562d351320e09f89534b636f674eb4034694/test/addon/test_cppcheckdata.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/cppcheck-opensource/cppcheck/pull/8999/{{ revealButtonHref }}
https://github.com/cppcheck-opensource/cppcheck/pull/8999/files#diff-8e1ef950d717b15d0e188c070e1adc26e784f282c38f8cb193c4f9cc288d6c90
https://github.com/cppcheck-opensource/cppcheck/pull/8999/files#diff-8e1ef950d717b15d0e188c070e1adc26e784f282c38f8cb193c4f9cc288d6c90
https://github.com/cppcheck-opensource/cppcheck/pull/8999/files#diff-8e1ef950d717b15d0e188c070e1adc26e784f282c38f8cb193c4f9cc288d6c90
https://github.com/cppcheck-opensource/cppcheck/pull/8999/files#diff-8e1ef950d717b15d0e188c070e1adc26e784f282c38f8cb193c4f9cc288d6c90
https://github.com/cppcheck-opensource/cppcheck/pull/8999/files#diff-8e1ef950d717b15d0e188c070e1adc26e784f282c38f8cb193c4f9cc288d6c90
https://github.com/cppcheck-opensource/cppcheck/pull/8999/files#diff-8e1ef950d717b15d0e188c070e1adc26e784f282c38f8cb193c4f9cc288d6c90
Please reload this pagehttps://github.com/cppcheck-opensource/cppcheck/pull/8999/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.