Remove <string> includes in headers to improve build time#1840
Merged
Conversation
Ivorforce
approved these changes
Sep 9, 2025
Ivorforce
left a comment
Member
There was a problem hiding this comment.
Makes sense to me. We do not use std::string with godot-cpp. So it should be good as long as it compiles.
Collaborator
|
Thanks! |
Collaborator
|
Cherry-picked for 4.4 in PR #1871 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
<string>header was inclass_db.hppandmethod_bind.hppeven though no parts of it are used in either of those files. I also removed the<iostream>header from class_db.hpp because it was also unused. Both of these files ended up getting included in thousands of other cpp files so slowed down build time a lot.There seem to be only 2 uses of code from
<string>in godot-cpp as the code works now:I did 2 test runs where I ran with ClangBuildAnalyzer and the
timecommand then didscons --clean. These are the timings I got before and after making these changes:Without these changes
Executed in 108.61 secs
Executed in 107.91 secs
**** Time summary:
Compilation (1025 times):
Parsing (frontend): 1701.6 s
Codegen & opts (backend): 187.1 s
With these changes
Executed in 97.04 secs
Executed in 91.19 secs
**** Time summary:
Compilation (1025 times):
Parsing (frontend): 1393.1 s
Codegen & opts (backend): 181.2 s