read/cfi: minor CIE/FDE parsing optimisation#866
Merged
philipc merged 1 commit intogimli-rs:masterfrom Jan 20, 2026
Merged
Conversation
When asked to parse a CIE, we would fully parse any CIE or FDE at the offset, and then discard the result if it was an FDE. Similarly for parsing an FDE. Optimise this by doing the check of the CIE ID immediately. In practice this is unlikely to make any difference, because the entries will always be the expected type if the data is valid. Additionally, we had `Error::NotCieId`, `Error::NotCiePointer`, and `Error::NotFdePointer`, but `Error::NotCiePointer` was not used. However, `Error::NotCiePointer` is the more logical error for the situation where `Error::NotFdePointer` was used, so switch to it and delete `Error::NotFdePointer`. The git history shows that at some point we already did both of the above (which is why `NotCiePointer` existed), but they were lost along the way during refactoring. Also reorder some function parameters for consistency.
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.
When asked to parse a CIE, we would fully parse any CIE or FDE at the offset, and then discard the result if it was an FDE. Similarly for parsing an FDE. Optimise this by doing the check of the CIE ID immediately. In practice this is unlikely to make any difference, because the entries will always be the expected type if the data is valid.
Additionally, we had
Error::NotCieId,Error::NotCiePointer, andError::NotFdePointer, butError::NotCiePointerwas not used. However,Error::NotCiePointeris the more logical error for the situation whereError::NotFdePointerwas used, so switch to it and deleteError::NotFdePointer.The git history shows that at some point we already did both of the above (which is why
NotCiePointerexisted), but they were lost along the way during refactoring.Also reorder some function parameters for consistency.