-
Notifications
You must be signed in to change notification settings - Fork 282
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
Use std::map for faster lookup #2299
Conversation
Codecov Report
@@ Coverage Diff @@
## main #2299 +/- ##
=======================================
Coverage 63.53% 63.54%
=======================================
Files 118 118
Lines 19595 19597 +2
Branches 9576 9579 +3
=======================================
+ Hits 12450 12452 +2
Misses 5079 5079
Partials 2066 2066
Help us with your feedback. Take ten seconds to tell us how you rate us. |
87d1055
to
9a3f567
Compare
On a somewhat related note, I wonder if it was a mistake to replace function pointers with std::function... |
@@ -146,29 +146,13 @@ struct TiffImgTagStruct { | |||
IfdId group_; //!< Group that contains the image tag |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this whole struct be replaced with
using TiffImgTagStruct = std::pair<uint16_t, IfdId>;
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I agree. And this looks inefficient too:
Line 2118 in ee5dae4
return find(tiffImageTags, TiffImgTagStruct::Key(tag, group)); |
I think those changes should go in a separate PR though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what I can tell, this find function is a wrapper over std::find.
e04a9ff
to
7498fa6
Compare
|
I think I need to investigate why one of the tests failed. |
OSS-Fuzz reported a timeout. It's not serious problem - just a moderately large file that's a bit slow to process. But I noticed that it's spending a lot of time in this line of code:
exiv2/src/tiffimage_int.cpp
Line 1811 in ee5dae4
It's doing a linear search of a 358-element array, which is a bit slow. This PR replaces the array with a
std::map
, which improves the running time on this particular file by approximately 10%.poc:
time exiv2 poc.jpg