diff options
author | Neil <nyamatongwe@gmail.com> | 2018-10-15 09:05:52 +1100 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2018-10-15 09:05:52 +1100 |
commit | e21a8ca7ecf4001bb3c9a6bcc9d415e60ba2b303 (patch) | |
tree | 5ecf5adf895965fe2652e4d01eb2a95e0781de14 /src/Document.h | |
parent | c804e5578b41b3523e5cb933fd40d08ba132b347 (diff) | |
download | scintilla-mirror-e21a8ca7ecf4001bb3c9a6bcc9d415e60ba2b303.tar.gz |
Extract duration measurement damping and clamping into ActionDuration class so
that it can be reused.
Diffstat (limited to 'src/Document.h')
-rw-r--r-- | src/Document.h | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/Document.h b/src/Document.h index 0ef967e09..19a03ad1d 100644 --- a/src/Document.h +++ b/src/Document.h @@ -190,6 +190,26 @@ struct RegexError : public std::runtime_error { }; /** + * The ActionDuration class stores the average time taken for some action such as styling or + * wrapping a line. It is used to decide how many repetitions of that action can be performed + * on idle to maximize efficiency without affecting application responsiveness. + * The duration changes if the time for the action changes. For example, if a simple lexer is + * changed to a complex lexer. Changes are damped and clamped to avoid short periods of easy + * or difficult processing moving the value too far leading to inefficiency or poor user + * experience. + */ + +class ActionDuration { + double duration; + const double minDuration; + const double maxDuration; +public: + ActionDuration(double duration_, double minDuration_, double maxDuration_) noexcept; + void AddSample(size_t numberActions, double durationOfActions) noexcept; + double Duration() const noexcept; +}; + +/** */ class Document : PerLine, public IDocument, public ILoader { @@ -259,7 +279,7 @@ public: bool useTabs; bool tabIndents; bool backspaceUnindents; - double durationStyleOneLine; + ActionDuration durationStyleOneLine; std::unique_ptr<IDecorationList> decorations; |