Optimize EOF by reading types on demand#1034
Merged
chfast merged 1 commit intoOct 14, 2024
Merged
Conversation
Contributor
Author
|
This PR addresses: #1003 |
chfast
requested changes
Sep 27, 2024
chfast
reviewed
Oct 7, 2024
chfast
reviewed
Oct 9, 2024
| if (type_section_size != code_sizes.size() * 4) | ||
| return EOFValidationError::invalid_type_section_size; | ||
|
|
||
| auto validation_error = validate_types(container, type_section_offset, type_section_size); |
Member
There was a problem hiding this comment.
This is quite an issue: validate_type() should not be used in validate_header() and invoke separately after validate_header(). This way we can just pass EOF1Header to validate_types() and use its .get_type() method.
But maybe this requires a separate PR. What do you think @gumb0?
Member
There was a problem hiding this comment.
Sounds good to try in a separate PR.
It made sense to do it here before, becase "validate header" really meant "validate header and types and return them togethere in one struct"
gumb0
reviewed
Oct 10, 2024
| uint8_t version = 0; | ||
|
|
||
| /// Size of every type section. | ||
| uint16_t type_section_size = 0; |
Member
There was a problem hiding this comment.
We don't need to store the size at all, because header validation guarantees that type_section_size == code_sizes.siz() * 4
Introduces `EOF1Header::get_type` function to read individual EOF code types. This is fast procedure because we need to read at most 4 bytes and a know offset. By doing so we avoid allocating separated vector to types.
chfast
approved these changes
Oct 14, 2024
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.
Introduces
EOF1Header::get_typefunction to read individual EOFcode types. This is fast procedure because we need to read at most 4
bytes and a know offset. By doing so we avoid allocating separated
vector to types.
Closes #1003.