aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/PositionCache.h
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2021-06-10 16:03:47 +1000
committerNeil <nyamatongwe@gmail.com>2021-06-10 16:03:47 +1000
commit1fdd0b8dc8f2895c5942b23410f11ea21dd4e3f4 (patch)
tree662dc6fd61303a2f40bc883ab2b574b503a6c9ee /src/PositionCache.h
parent6d353d5ced87c554bc1b9abe194f18d585a0aeef (diff)
downloadscintilla-mirror-1fdd0b8dc8f2895c5942b23410f11ea21dd4e3f4.tar.gz
Use string_view for PositionCache methods.
Replace custom hash code with standard library hash. Drop standard methods that are not needed. Restrict representations to 200 bytes. Improve documentation.
Diffstat (limited to 'src/PositionCache.h')
-rw-r--r--src/PositionCache.h17
1 files changed, 6 insertions, 11 deletions
diff --git a/src/PositionCache.h b/src/PositionCache.h
index 030b16504..b628b0421 100644
--- a/src/PositionCache.h
+++ b/src/PositionCache.h
@@ -188,16 +188,17 @@ public:
void operator=(const PositionCacheEntry &) = delete;
void operator=(PositionCacheEntry &&) = delete;
~PositionCacheEntry();
- void Set(unsigned int styleNumber_, const char *s_, unsigned int len_, const XYPOSITION *positions_, unsigned int clock_);
+ void Set(unsigned int styleNumber_, std::string_view sv, const XYPOSITION *positions_, unsigned int clock_);
void Clear() noexcept;
- bool Retrieve(unsigned int styleNumber_, const char *s_, unsigned int len_, XYPOSITION *positions_) const noexcept;
- static unsigned int Hash(unsigned int styleNumber_, const char *s, unsigned int len_) 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;
bool NewerThan(const PositionCacheEntry &other) const noexcept;
void ResetClock() noexcept;
};
class Representation {
public:
+ static constexpr size_t maxLength = 200;
std::string stringRep;
RepresentationAppearance appearance;
ColourRGBA colour;
@@ -271,17 +272,11 @@ class PositionCache {
bool allClear;
public:
PositionCache();
- // Deleted so PositionCache objects can not be copied.
- PositionCache(const PositionCache &) = delete;
- PositionCache(PositionCache &&) = delete;
- void operator=(const PositionCache &) = delete;
- void operator=(PositionCache &&) = delete;
- ~PositionCache();
void Clear() noexcept;
void SetSize(size_t size_);
- size_t GetSize() const noexcept { return pces.size(); }
+ size_t GetSize() const noexcept;
void MeasureWidths(Surface *surface, const ViewStyle &vstyle, unsigned int styleNumber,
- const char *s, unsigned int len, XYPOSITION *positions);
+ std::string_view sv, XYPOSITION *positions);
};
}