aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/PositionCache.h
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2021-09-28 12:08:09 +1000
committerNeil <nyamatongwe@gmail.com>2021-09-28 12:08:09 +1000
commit810964f8e6b80fbfdb7f96b9a084acc4cbe5a3a1 (patch)
treeef68c28d8c9f92f328a8f765c77092b849ecdd77 /src/PositionCache.h
parent2f038d69e4c79d3dfb9979ad28d0c6b0f30e823c (diff)
downloadscintilla-mirror-810964f8e6b80fbfdb7f96b9a084acc4cbe5a3a1.tar.gz
Widen styleNumber in PositionCacheEntry from 8 to 16 bits to allow styles
larger than 255 to be represented. Before this, it may have been possible but extremely rare for a cache entry to wrongly match a styled lexeme and produce incorrect layout. Using uint16_t from cstdint instead of a bit field as tools perform more checking on that.
Diffstat (limited to 'src/PositionCache.h')
-rw-r--r--src/PositionCache.h10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/PositionCache.h b/src/PositionCache.h
index 3dc68a0fd..79d63ee75 100644
--- a/src/PositionCache.h
+++ b/src/PositionCache.h
@@ -172,9 +172,9 @@ public:
};
class PositionCacheEntry {
- unsigned int styleNumber:8;
- unsigned int len:8;
- unsigned int clock:16;
+ uint16_t styleNumber;
+ uint16_t len;
+ uint16_t clock;
std::unique_ptr<XYPOSITION []> positions;
public:
PositionCacheEntry() noexcept;
@@ -185,7 +185,7 @@ public:
void operator=(const PositionCacheEntry &) = delete;
void operator=(PositionCacheEntry &&) = delete;
~PositionCacheEntry();
- void Set(unsigned int styleNumber_, std::string_view sv, const XYPOSITION *positions_, unsigned int clock_);
+ void Set(unsigned int styleNumber_, std::string_view sv, const XYPOSITION *positions_, uint16_t clock_);
void Clear() noexcept;
bool Retrieve(unsigned int styleNumber_, std::string_view sv, XYPOSITION *positions_) const noexcept;
static size_t Hash(unsigned int styleNumber_, std::string_view sv) noexcept;
@@ -273,7 +273,7 @@ public:
class PositionCache {
std::vector<PositionCacheEntry> pces;
- unsigned int clock;
+ uint16_t clock;
bool allClear;
public:
PositionCache();