Skip to content
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

Replace Metadatum::toLong() with Metadatum::toInt64(). #2107

Merged
merged 4 commits into from
Feb 19, 2022

Conversation

kevinbackhouse
Copy link
Collaborator

Follow-up to #2062: replace long in Metadatum with platform-independent int64_t.

@kevinbackhouse kevinbackhouse marked this pull request as draft February 18, 2022 12:33
@codecov
Copy link

codecov bot commented Feb 18, 2022

Codecov Report

Merging #2107 (a7ce4ee) into main (15c91b4) will increase coverage by 0.05%.
The diff coverage is 62.36%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2107      +/-   ##
==========================================
+ Coverage   63.75%   63.80%   +0.05%     
==========================================
  Files          96       96              
  Lines       19202    19171      -31     
  Branches     9798     9772      -26     
==========================================
- Hits        12242    12232      -10     
  Misses       4658     4658              
+ Partials     2302     2281      -21     
Impacted Files Coverage Δ
include/exiv2/bmffimage.hpp 100.00% <ø> (ø)
include/exiv2/exif.hpp 100.00% <ø> (ø)
include/exiv2/image.hpp 100.00% <ø> (ø)
include/exiv2/iptc.hpp 100.00% <ø> (ø)
include/exiv2/metadatum.hpp 72.72% <ø> (ø)
include/exiv2/pgfimage.hpp 100.00% <ø> (ø)
include/exiv2/xmp_exiv2.hpp 92.30% <ø> (ø)
src/cr2image.cpp 19.48% <0.00%> (ø)
src/iptc.cpp 64.20% <0.00%> (ø)
src/mrwimage.cpp 45.94% <0.00%> (ø)
... and 36 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 15c91b4...a7ce4ee. Read the comment docs.

@piponazo
Copy link
Collaborator

It looks good to me so far. I'll happily approve when you think the PR is "Ready for review"

src/preview.cpp Outdated
@@ -506,8 +506,8 @@ namespace {
return false;
image->readMetadata();

width_ = image->pixelWidth();
height_ = image->pixelHeight();
width_ = static_cast<uint32_t>(image->pixelWidth());
Copy link
Collaborator

@piponazo piponazo Feb 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hum ... I am a bit skeptical about this change. I noticed that in your second commit (76d4748) you changed pixelWidth and pixelHeight from int to int64_t, not only in the function members but also in the class members Image::pixelWidth_ and Image::pixelHeight_.

What's the rationale for addressing these changes? Maybe you should change also this height_ and width_ at in the preview files ?

In your first commit (2563658) I noticed that after making the change you could get rid of some static_casts. It is always good to get rid of them, their presence signal that something is not modeled correctly.

However in the last commits I noticed that you had to add few static_casts here and there. This make me a bit nervous ... unless you have a good reason for it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, I've been lazy here: swapping int with int64_t in the header was the easiest way to switch it to a platform-independent type. But uint32_t is probably a more appropriate choice for pixelWidth and pixelHeight.

I'll convert this PR back to draft and work on it a bit more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added Metadatum::toUint32() so that the code doesn't need to do any static casts. The implementation of Metadatum::toUint32() currently just does a static_cast but we could easily add overflow checking in the future if we want to.

@kevinbackhouse kevinbackhouse marked this pull request as draft February 18, 2022 16:20
@kevinbackhouse kevinbackhouse marked this pull request as ready for review February 18, 2022 22:47
@kevinbackhouse kevinbackhouse added the refactoring Cleanup / Simplify code -> more readable / robust label Feb 19, 2022
@kevinbackhouse kevinbackhouse added this to the v1.00 milestone Feb 19, 2022
Copy link
Collaborator

@piponazo piponazo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring Cleanup / Simplify code -> more readable / robust
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants