Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace slower boost::lexical_cast with stdlib conversions #3997

Merged
merged 1 commit into from
Mar 10, 2022

Conversation

ranisalt
Copy link
Member

@ranisalt ranisalt commented Mar 9, 2022

Pull Request Prelude

Changes Proposed

Replaces the slow boost::lexical_cast calls with standard library functions for a... boost in performance! Results vary from type to type, on my machine it is at least 2x faster across the board for integers, and 150x faster for bytes (signed and unsigned char), and 8x faster for floats. The difference is slightly smaller on godbolt as you can see.

Yes, it is necessary to specify both char and signed char because they might not map to the same type (on my machine, int8_t maps to signed char and the char-only version does not apply). Same goes for int and long.

This is not on a critical path and the improvement might not be significant. Notably, it may speed up XML parsing (which is fast anyway) and loading data from the database.

@ranisalt ranisalt requested a review from EPuncker March 9, 2022 23:32
@EPuncker EPuncker merged commit 3fb22fb into otland:master Mar 10, 2022
@ranisalt ranisalt deleted the perf/std-cast branch March 10, 2022 08:43
Codinablack pushed a commit to Codinablack/forgottenserver that referenced this pull request Apr 5, 2022
EPuncker pushed a commit to EPuncker/forgottenserver that referenced this pull request May 23, 2023
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.

None yet

2 participants