aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/PositionCache.cxx
diff options
context:
space:
mode:
authorNeil <devnull@localhost>2014-05-02 22:02:02 +1000
committerNeil <devnull@localhost>2014-05-02 22:02:02 +1000
commit5a1126b68cbcd6b49534e9daa0eebe3a354e3f73 (patch)
treed2924ad9c0a97a8b50a515389a171c458524e554 /src/PositionCache.cxx
parent58fae22fa1c882b1d3451d3f2d5b7f8907341d09 (diff)
downloadscintilla-mirror-5a1126b68cbcd6b49534e9daa0eebe3a354e3f73.tar.gz
Use unsigned int for calculating hash and secondary probe as overflow of signed
int is undefined in C++.
Diffstat (limited to 'src/PositionCache.cxx')
-rw-r--r--src/PositionCache.cxx4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/PositionCache.cxx b/src/PositionCache.cxx
index f197a6559..820fd4895 100644
--- a/src/PositionCache.cxx
+++ b/src/PositionCache.cxx
@@ -594,7 +594,7 @@ bool PositionCacheEntry::Retrieve(unsigned int styleNumber_, const char *s_,
}
}
-int PositionCacheEntry::Hash(unsigned int styleNumber_, const char *s, unsigned int len_) {
+unsigned int PositionCacheEntry::Hash(unsigned int styleNumber_, const char *s, unsigned int len_) {
unsigned int ret = s[0] << 7;
for (unsigned int i=0; i<len_; i++) {
ret *= 1000003;
@@ -652,7 +652,7 @@ void PositionCache::MeasureWidths(Surface *surface, ViewStyle &vstyle, unsigned
// long comments with only a single comment.
// Two way associative: try two probe positions.
- int hashValue = PositionCacheEntry::Hash(styleNumber, s, len);
+ unsigned int hashValue = PositionCacheEntry::Hash(styleNumber, s, len);
probe = static_cast<int>(hashValue % pces.size());
if (pces[probe].Retrieve(styleNumber, s, len, positions)) {
return;