openzim / libzim

Reference implementation of the ZIM specification
https://download.openzim.org/release/libzim/
GNU General Public License v2.0
164 stars 50 forks source link

Reintroduce Optimization of Entry::getItem() #836

Closed kelson42 closed 10 months ago

kelson42 commented 10 months ago

Fixes #769

For a client of libzim the only way to create an Item object is through Entry::getItem() or Entry::getRedirect() (the latter relying on the former to deliver the final result).

Before this change, Entry::getItem() performed (via the Item constructor) an extra call to FileImpl::getDirent(entry_index_t). Now the result of that operation that is readily available in the source Entry object is reused.

codecov[bot] commented 10 months ago

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (2a810ac) 57.57% compared to head (c23d43e) 57.57%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #836 +/- ## ========================================== - Coverage 57.57% 57.57% -0.01% ========================================== Files 98 99 +1 Lines 4545 4542 -3 Branches 1911 1909 -2 ========================================== - Hits 2617 2615 -2 Misses 668 668 + Partials 1260 1259 -1 ``` | [Files](https://app.codecov.io/gh/openzim/libzim/pull/836?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=openzim) | Coverage Δ | | |---|---|---| | [include/zim/entry.h](https://app.codecov.io/gh/openzim/libzim/pull/836?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=openzim#diff-aW5jbHVkZS96aW0vZW50cnkuaA==) | `100.00% <ø> (ø)` | | | [include/zim/item.h](https://app.codecov.io/gh/openzim/libzim/pull/836?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=openzim#diff-aW5jbHVkZS96aW0vaXRlbS5o) | `100.00% <100.00%> (ø)` | | | [src/entry.cpp](https://app.codecov.io/gh/openzim/libzim/pull/836?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=openzim#diff-c3JjL2VudHJ5LmNwcA==) | `60.60% <100.00%> (+3.03%)` | :arrow_up: | | [src/item.cpp](https://app.codecov.io/gh/openzim/libzim/pull/836?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=openzim#diff-c3JjL2l0ZW0uY3Bw) | `57.57% <66.66%> (-5.59%)` | :arrow_down: |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.