Highlighter engine returns cached spans by reference; drop unneeded mutexes
HighlighterEngine::GetLine copied the span vector on every call (twice on a miss) and did a dynamic_cast per call; it now returns the cached entry (valid until the next call) and dispatches on Stateful(). PieceTable and HighlighterEngine took a mutex in their read paths while their writes took none, and PieceTable.h claimed concurrent reads were safe; they are not (reads update caches). Every Buffer is used from the main thread only (the swap writer thread receives copies; the regex large-stack thread runs while its caller waits), so the mutexes are removed and the headers say so. ASan and the threaded tests under TSan are clean. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015rcVQiiWyTzoNrsvLSaAfB
This commit is contained in:
+2
-4
@@ -33,7 +33,8 @@
|
||||
*
|
||||
* Implementation notes:
|
||||
* - Consolidation heuristics prevent piece fragmentation (configurable via SetConsolidationParams)
|
||||
* - Thread-safe for concurrent reads (mutex protects caches and lazy rebuilds)
|
||||
* - Not thread-safe: even reads update caches. Buffers are used from the
|
||||
* main thread only (the swap writer thread gets copies of the bytes).
|
||||
* - Version tracking invalidates caches on mutations
|
||||
*/
|
||||
#pragma once
|
||||
@@ -43,7 +44,6 @@
|
||||
#include <ostream>
|
||||
#include <vector>
|
||||
#include <limits>
|
||||
#include <mutex>
|
||||
#include <string_view>
|
||||
|
||||
#include "TextSpan.h"
|
||||
@@ -297,6 +297,4 @@ private:
|
||||
|
||||
mutable RangeCache range_cache_;
|
||||
mutable FindCache find_cache_;
|
||||
|
||||
mutable std::mutex mutex_;
|
||||
};
|
||||
Reference in New Issue
Block a user