diff options
author | Neil <devnull@localhost> | 2014-05-02 22:02:02 +1000 |
---|---|---|
committer | Neil <devnull@localhost> | 2014-05-02 22:02:02 +1000 |
commit | 5a1126b68cbcd6b49534e9daa0eebe3a354e3f73 (patch) | |
tree | d2924ad9c0a97a8b50a515389a171c458524e554 | |
parent | 58fae22fa1c882b1d3451d3f2d5b7f8907341d09 (diff) | |
download | scintilla-mirror-5a1126b68cbcd6b49534e9daa0eebe3a354e3f73.tar.gz |
Use unsigned int for calculating hash and secondary probe as overflow of signed
int is undefined in C++.
-rw-r--r-- | src/PositionCache.cxx | 4 | ||||
-rw-r--r-- | src/PositionCache.h | 2 |
2 files changed, 3 insertions, 3 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; diff --git a/src/PositionCache.h b/src/PositionCache.h index 871bb6e46..d8ea0119d 100644 --- a/src/PositionCache.h +++ b/src/PositionCache.h @@ -111,7 +111,7 @@ public: void Set(unsigned int styleNumber_, const char *s_, unsigned int len_, XYPOSITION *positions_, unsigned int clock); void Clear(); bool Retrieve(unsigned int styleNumber_, const char *s_, unsigned int len_, XYPOSITION *positions_) const; - static int Hash(unsigned int styleNumber_, const char *s, unsigned int len); + static unsigned int Hash(unsigned int styleNumber_, const char *s, unsigned int len); bool NewerThan(const PositionCacheEntry &other) const; void ResetClock(); }; |