Skip to content

Optimize content type detection using C-strings#225

Merged
me-no-dev merged 2 commits into
ESP32Async:mainfrom
JosePineiro:optimize-content-type-detection
Jul 11, 2025
Merged

Optimize content type detection using C-strings#225
me-no-dev merged 2 commits into
ESP32Async:mainfrom
JosePineiro:optimize-content-type-detection

Conversation

@JosePineiro

Copy link
Copy Markdown

Optimize _setContentTypeFromPath method with a more efficient version (_setContentTypeFromPath_v3) that uses C-string comparison (strcmp) instead of String::endsWith. This change improves performance and reduces memory usage, Common web extensions are checked first to speed up typical lookups.

Version 1 (original): 16.9789 μs per call
Version 2 (strcmp): 6.7527 μs per call

You can compare the performance using the
main.cpp.txt

Optimize _setContentTypeFromPath method with a more efficient version (_setContentTypeFromPath_v3) that uses C-string comparison (strcmp) instead of String::endsWith.
This change improves performance and reduces memory usage,
Common web extensions are checked first to speed up typical lookups.

Version 1 (original):    16.9789 μs per call
Version 2 (strcmp):      6.7527 μs per call
@me-no-dev me-no-dev merged commit 615cff7 into ESP32Async:main Jul 11, 2025
33 checks passed
@JosePineiro JosePineiro deleted the optimize-content-type-detection branch July 14, 2025 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants