Png: avoid multiplication at int precision, then converting to long

Change-Id: Id05d1db07ae7e8978b2a6b989b6366ae66d0e9de
This commit is contained in:
Miklos Vajna 2016-12-05 11:56:12 +01:00
parent d4d4a11750
commit 6a08b44433
2 changed files with 3 additions and 3 deletions

View file

@ -1,3 +1,3 @@
Checks: 'clang-diagnostic-*,performance-*,unused-*,misc-*,-misc-macro-parentheses,readability-redundant-*' Checks: 'clang-diagnostic-*,performance-*,unused-*,misc-*,-misc-macro-parentheses,readability-redundant-*,-readability-redundant-declaration'
WarningsAsErrors: '*' WarningsAsErrors: '*'

View file

@ -160,14 +160,14 @@ bool encodeBufferToPNG(unsigned char* pixmap, int width, int height,
} }
inline inline
uint64_t hashBuffer(unsigned char* pixmap, int width, int height) uint64_t hashBuffer(unsigned char* pixmap, long width, long height)
{ {
return SpookyHash::Hash64(pixmap, width * height * 4, 1073741789); return SpookyHash::Hash64(pixmap, width * height * 4, 1073741789);
} }
inline inline
uint64_t hashSubBuffer(unsigned char* pixmap, size_t startX, size_t startY, uint64_t hashSubBuffer(unsigned char* pixmap, size_t startX, size_t startY,
int width, int height, int bufferWidth, int bufferHeight) long width, long height, int bufferWidth, int bufferHeight)
{ {
if (bufferWidth < width || bufferHeight < height) if (bufferWidth < width || bufferHeight < height)
return 0; // magic invalid hash. return 0; // magic invalid hash.