Skip to content

Commit 9074ff4

Browse files
committed
avoid unnecessary shifting
1 parent 787fb98 commit 9074ff4

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

encoding.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ extern "C" {
1414
#include "ZendUtil.h"
1515
#include <algorithm>
1616
#include <iterator>
17+
#include <type_traits>
1718

1819
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_read_integer, 0, 0, IS_LONG, 0)
1920
ZEND_END_ARG_INFO()
@@ -137,7 +138,7 @@ static inline bool readInt24(unsigned char* bytes, size_t used, size_t& offset,
137138
result |= bytes[offset] << 16;
138139
}
139140

140-
const size_t SIGNED_SHIFT = (sizeof(TValue) - SIZE) * CHAR_BIT;
141+
const size_t SIGNED_SHIFT = std::is_signed<TValue>::value ? (sizeof(TValue) - SIZE) * CHAR_BIT : 0;
141142
if (SIGNED_SHIFT > 0) {
142143
result = (result << SIGNED_SHIFT) >> SIGNED_SHIFT;
143144
}

0 commit comments

Comments
 (0)