René's URL Explorer Experiment


Title: Include and path handling optimization by glankk · Pull Request #447 · cppcheck-opensource/simplecpp · GitHub

Open Graph Title: Include and path handling optimization by glankk · Pull Request #447 · cppcheck-opensource/simplecpp

X Title: Include and path handling optimization by glankk · Pull Request #447 · cppcheck-opensource/simplecpp

Description: This is a draft with some suggested changes to how includes are handled. There are several style issues at the moment, but I would like to discuss the overall approach before addressing those. The changes to the include lookup procedure are based on the observation that files are very often included multiple times, but very rarely included with a different name. To take advantage of this, the lookup procedure first tries to do an optimistic match using the quick and simple path canonicalization provided by simplifyPath. In the rare case that a file is included with a name that hasn't been seen before (due to absoluteness change, capitalization, or link), then and only then is that file compared against the cached files using a more accurate but expensive procedure. For the case where the file identity cannot be determined with simplifyPath, the file id is used (FILE_ID_INFO on windows, st_dev & st_ino on linux). This combined with the fact that file identity checking is delayed until absolutely necessary means that all calls to realFilename have been removed. This is where most of the timesave comes from. Using file id means that the lookup procedure has less platform-specific code (only for getting and comparing the file id), and the behavior for case-sensitivty and links is uniform across platforms. The behavior for symlinks matches that of gcc and clang, which is to allows pragma once to work when a file is included with a different name. There's no standard definition for what pragma once should do, but personally I think this is the desired behavior. Intuitively, there are no situations where it is desirable for #pragma once to produce redefinition errors if a file is included multiple times using different names. The code runs about 2 minutes faster for a large test case on windows with many nested includes (12m40s down from 14m40s), though it's a contrived test case so I'm not sure how representative that is of a real use case. Some other things; The new procedure requires some additional metadata. Instead of adding more static data in simplecpp, I've opted to place both the token lists and metadata in a new class for the sake of better structure. Other file-specific optimizations could also be facilitated by this such as the multiple-include optimization used by gcc, though using a class is not strictly necessary and does incur a change to the simplecpp interface. Some c++11 features are used, but these could be removed or placed in ifdefs. The rules for how simplecpp should search for headers are not always clear, ideally this would be stated precisely somewhere to make sure that the implementation is correct. Specifically, gcc and clang does not look in the current working directory unless -I. is explicitly passed, but simplecpp does. I would like to clarify whether or not this is intentional or if the behavior should match other compilers.

Open Graph Description: This is a draft with some suggested changes to how includes are handled. There are several style issues at the moment, but I would like to discuss the overall approach before addressing those. The ...

X Description: This is a draft with some suggested changes to how includes are handled. There are several style issues at the moment, but I would like to discuss the overall approach before addressing those. The ...

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

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:71a5d31e-6b98-bb2c-73f1-e5b889558857
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id9CFE:1730DB:4DCADA8:6DFABE4:6A501D79
html-safe-nonce99ad315b1313437e01d09f65b5214f57f9f1e071895e25dc9937762fb8728306
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5Q0ZFOjE3MzBEQjo0RENBREE4OjZERkFCRTQ6NkE1MDFENzkiLCJ2aXNpdG9yX2lkIjoiNjA5MDE3MTAxMDgzNjg2NDM3NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac0765086482ee5b6140a548124eeb459b5c5ea59b3ecd111830ac5ba273a6f0eb
hovercard-subject-tagpull_request:2614933694
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/simplecpp/pull/447/files
twitter:imagehttps://avatars.githubusercontent.com/u/10298420?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/10298420?s=400&v=4
og:image:altThis is a draft with some suggested changes to how includes are handled. There are several style issues at the moment, but I would like to discuss the overall approach before addressing those. The ...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None14f013003d3992e8746116a6f2f55cd2fdaccd329ee0423392831ae051ecb535
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/cppcheck-opensource/simplecpp git https://github.com/cppcheck-opensource/simplecpp.git
octolytics-dimension-user_id278097703
octolytics-dimension-user_logincppcheck-opensource
octolytics-dimension-repository_id33434464
octolytics-dimension-repository_nwocppcheck-opensource/simplecpp
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id33434464
octolytics-dimension-repository_network_root_nwocppcheck-opensource/simplecpp
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
release26ee7c1a62943cf19a6fcc1d1ac93ac83465c885
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/cppcheck-opensource/simplecpp/pull/447/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fcppcheck-opensource%2Fsimplecpp%2Fpull%2F447%2Ffiles
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
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
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://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
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fcppcheck-opensource%2Fsimplecpp%2Fpull%2F447%2Ffiles
Sign up https://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%2Fsimplecpp
Reloadhttps://github.com/cppcheck-opensource/simplecpp/pull/447/files
Reloadhttps://github.com/cppcheck-opensource/simplecpp/pull/447/files
Reloadhttps://github.com/cppcheck-opensource/simplecpp/pull/447/files
Please reload this pagehttps://github.com/cppcheck-opensource/simplecpp/pull/447/files
cppcheck-opensource https://github.com/cppcheck-opensource
simplecpphttps://github.com/cppcheck-opensource/simplecpp
Notifications https://github.com/login?return_to=%2Fcppcheck-opensource%2Fsimplecpp
Fork 104 https://github.com/login?return_to=%2Fcppcheck-opensource%2Fsimplecpp
Star 263 https://github.com/login?return_to=%2Fcppcheck-opensource%2Fsimplecpp
Code https://github.com/cppcheck-opensource/simplecpp
Issues 82 https://github.com/cppcheck-opensource/simplecpp/issues
Pull requests 31 https://github.com/cppcheck-opensource/simplecpp/pulls
Actions https://github.com/cppcheck-opensource/simplecpp/actions
Wiki https://github.com/cppcheck-opensource/simplecpp/wiki
Security and quality 0 https://github.com/cppcheck-opensource/simplecpp/security
Insights https://github.com/cppcheck-opensource/simplecpp/pulse
Code https://github.com/cppcheck-opensource/simplecpp
Issues https://github.com/cppcheck-opensource/simplecpp/issues
Pull requests https://github.com/cppcheck-opensource/simplecpp/pulls
Actions https://github.com/cppcheck-opensource/simplecpp/actions
Wiki https://github.com/cppcheck-opensource/simplecpp/wiki
Security and quality https://github.com/cppcheck-opensource/simplecpp/security
Insights https://github.com/cppcheck-opensource/simplecpp/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fcppcheck-opensource%2Fsimplecpp%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%2Fsimplecpp%2Fissues%2Fnew%2Fchoose
danmarhttps://github.com/danmar
cppcheck-opensource:masterhttps://github.com/cppcheck-opensource/simplecpp/tree/master
glankk:optimize_pathshttps://github.com/glankk/simplecpp/tree/optimize_paths
Conversation 14 https://github.com/cppcheck-opensource/simplecpp/pull/447
Commits 19 https://github.com/cppcheck-opensource/simplecpp/pull/447/commits
Checks 15 https://github.com/cppcheck-opensource/simplecpp/pull/447/checks
Files changed 5 https://github.com/cppcheck-opensource/simplecpp/pull/447/files
Include and path handling optimization https://github.com/cppcheck-opensource/simplecpp/pull/447/files#top
Show all changes 19 commits https://github.com/cppcheck-opensource/simplecpp/pull/447/files
de99c5d optimize paths glankk Jun 19, 2025 https://github.com/cppcheck-opensource/simplecpp/pull/447/commits/de99c5d410c942b18b1933d1acb13d6933025a0d
a3300df Cleanup and fixes glankk Jun 27, 2025 https://github.com/cppcheck-opensource/simplecpp/pull/447/commits/a3300df9b1312561818cb1cc1c418cdb9c42b46d
fd84870 Update to c++11 glankk Jun 28, 2025 https://github.com/cppcheck-opensource/simplecpp/pull/447/commits/fd848706314a146e825b22c5fcf4641269c22bf1
08bd742 Fix clang-tidy issues glankk Jun 28, 2025 https://github.com/cppcheck-opensource/simplecpp/pull/447/commits/08bd742d884a47f7f2f239180e0831a1e41a485c
791d4bb Fix windows definitions glankk Jun 30, 2025 https://github.com/cppcheck-opensource/simplecpp/pull/447/commits/791d4bbe26f61f877cc553cc00edbd3f138fa53c
5231eaa Merge branch 'master' into optimize_paths glankk Jul 3, 2025 https://github.com/cppcheck-opensource/simplecpp/pull/447/commits/5231eaad6052b7622c233b8b0ac1bcb1420d0598
d3fb424 Remove MyMutex and MyLock glankk Jul 3, 2025 https://github.com/cppcheck-opensource/simplecpp/pull/447/commits/d3fb4245e510b939d32e13ba86556fb7a094fa1f
60250e6 Simplify path calculations glankk Jul 3, 2025 https://github.com/cppcheck-opensource/simplecpp/pull/447/commits/60250e602ea790ab43bbec55237e4eaf976e389e
0c99e2c Rework lookup procedure glankk Jul 3, 2025 https://github.com/cppcheck-opensource/simplecpp/pull/447/commits/0c99e2cb6aa51cd7a5089368b87911f5b66830ca
06c2e8d Run astyle glankk Jul 3, 2025 https://github.com/cppcheck-opensource/simplecpp/pull/447/commits/06c2e8d603c52ef13531843480c11d3f28f6c3a2
4033f62 Fix clang-tidy issues glankk Jul 3, 2025 https://github.com/cppcheck-opensource/simplecpp/pull/447/commits/4033f629961952841487f7d86b59e0975614cd29
c40cf32 Fix windows include order glankk Jul 3, 2025 https://github.com/cppcheck-opensource/simplecpp/pull/447/commits/c40cf32a6899c2a7315dba608f26b2423959d972
f97e093 Fix FileID Hash for 32-bit hash glankk Jul 3, 2025 https://github.com/cppcheck-opensource/simplecpp/pull/447/commits/f97e0936ad93a26850c534a864876feb03a069d4
c47159d Fix early rejection glankk Jul 3, 2025 https://github.com/cppcheck-opensource/simplecpp/pull/447/commits/c47159dd73e3bfae2e42cc473d05b74b8131fcf4
91b0bf7 Fix shadowing style issue glankk Jul 3, 2025 https://github.com/cppcheck-opensource/simplecpp/pull/447/commits/91b0bf75520fa6a4de29cb6645a8d2695ea733ec
6c728b6 Run astyle glankk Jul 3, 2025 https://github.com/cppcheck-opensource/simplecpp/pull/447/commits/6c728b6cf12699a7d1c77c7a232a2ffc5f0b3546
946c344 Fix nits glankk Jul 4, 2025 https://github.com/cppcheck-opensource/simplecpp/pull/447/commits/946c3441d2b997384d126f041611e8390c6d383e
4e49366 Fix clang-tidy issues glankk Jul 4, 2025 https://github.com/cppcheck-opensource/simplecpp/pull/447/commits/4e4936653fd26ead66dd55ab4e9f93154562be4e
80860b2 Remove left over friend and forward declaration glankk Jul 4, 2025 https://github.com/cppcheck-opensource/simplecpp/pull/447/commits/80860b2c5f98041bedd2a5346872af2687db0dbf
Clear filters https://github.com/cppcheck-opensource/simplecpp/pull/447/files
Please reload this pagehttps://github.com/cppcheck-opensource/simplecpp/pull/447/files
Please reload this pagehttps://github.com/cppcheck-opensource/simplecpp/pull/447/files
integration_test.py https://github.com/cppcheck-opensource/simplecpp/pull/447/files#diff-1633196318a48ed42103653fbdf6e7c275dcd81969444fc01a47ae28beff077d
main.cpp https://github.com/cppcheck-opensource/simplecpp/pull/447/files#diff-608d8de3fba954c50110b6d7386988f27295de845e9d7174e40095ba5efcf1bb
simplecpp.cpp https://github.com/cppcheck-opensource/simplecpp/pull/447/files#diff-c847846a0c414ac05f52e4f9686648f22c76c9bb152579a253b600223c202832
simplecpp.h https://github.com/cppcheck-opensource/simplecpp/pull/447/files#diff-8feef6892144dbe750ffc83a1525c796968b56cd4d6500fe8bf22bac61cf9174
test.cpp https://github.com/cppcheck-opensource/simplecpp/pull/447/files#diff-042cc0321bd0d3c8cb8262c89142b3e6aba34345ae77b4294f5e07dd2687ffcf
integration_test.pyhttps://github.com/cppcheck-opensource/simplecpp/pull/447/files#diff-1633196318a48ed42103653fbdf6e7c275dcd81969444fc01a47ae28beff077d
View file https://github.com/glankk/simplecpp/blob/80860b2c5f98041bedd2a5346872af2687db0dbf/integration_test.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/cppcheck-opensource/simplecpp/pull/447/{{ revealButtonHref }}
https://github.com/cppcheck-opensource/simplecpp/pull/447/files#diff-1633196318a48ed42103653fbdf6e7c275dcd81969444fc01a47ae28beff077d
https://github.com/cppcheck-opensource/simplecpp/pull/447/files#diff-1633196318a48ed42103653fbdf6e7c275dcd81969444fc01a47ae28beff077d
https://github.com/cppcheck-opensource/simplecpp/pull/447/files#diff-1633196318a48ed42103653fbdf6e7c275dcd81969444fc01a47ae28beff077d
main.cpphttps://github.com/cppcheck-opensource/simplecpp/pull/447/files#diff-608d8de3fba954c50110b6d7386988f27295de845e9d7174e40095ba5efcf1bb
View file https://github.com/glankk/simplecpp/blob/80860b2c5f98041bedd2a5346872af2687db0dbf/main.cpp
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/cppcheck-opensource/simplecpp/pull/447/{{ revealButtonHref }}
https://github.com/cppcheck-opensource/simplecpp/pull/447/files#diff-608d8de3fba954c50110b6d7386988f27295de845e9d7174e40095ba5efcf1bb
https://github.com/cppcheck-opensource/simplecpp/pull/447/files#diff-608d8de3fba954c50110b6d7386988f27295de845e9d7174e40095ba5efcf1bb
https://github.com/cppcheck-opensource/simplecpp/pull/447/files#diff-608d8de3fba954c50110b6d7386988f27295de845e9d7174e40095ba5efcf1bb
https://github.com/cppcheck-opensource/simplecpp/pull/447/files#diff-608d8de3fba954c50110b6d7386988f27295de845e9d7174e40095ba5efcf1bb
Please reload this pagehttps://github.com/cppcheck-opensource/simplecpp/pull/447/files
Please reload this pagehttps://github.com/cppcheck-opensource/simplecpp/pull/447/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.