diff options
| author | Maxime Coste <mawww@kakoune.org> | 2021-06-24 16:42:45 +1000 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2021-06-24 17:20:37 +1000 |
| commit | be9b2de0ee811e8c4ec25e5b4b9ec1318c3799ed (patch) | |
| tree | afc5a321a619144dc5c228f72acdd8c909e45d47 /src/command_manager.hh | |
| parent | 49e2ecdcdb66ef5c0291f3ffc4d6616accd128a5 (diff) | |
Only compute command coordinates when necessary
Tracking the line/column of each token takes a surprising big part
of the command parsing logic runtime and is only necessary when we
hit an error.
Diffstat (limited to 'src/command_manager.hh')
| -rw-r--r-- | src/command_manager.hh | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/src/command_manager.hh b/src/command_manager.hh index 457b2a91..5150c08f 100644 --- a/src/command_manager.hh +++ b/src/command_manager.hh @@ -57,7 +57,6 @@ struct Token Type type; ByteCount pos; - BufferCoord coord; String content; bool terminated = false; }; @@ -65,7 +64,7 @@ struct Token struct Reader { public: - Reader(StringView s) : str{s}, pos{s.begin()}, line_start{s.begin()}, line{} {} + Reader(StringView s) : str{s}, pos{s.begin()} {} Codepoint operator*() const; Codepoint peek_next() const; @@ -74,12 +73,9 @@ public: explicit operator bool() const { return pos < str.end(); } StringView substr_from(const char* start) const { return {start, pos}; } - BufferCoord coord() const { return {line, (int)(pos - line_start)}; } StringView str; const char* pos; - const char* line_start; - LineCount line; }; class CommandParser @@ -89,7 +85,6 @@ public: Optional<Token> read_token(bool throw_on_unterminated); const char* pos() const { return m_reader.pos; } - BufferCoord coord() const { return m_reader.coord(); } bool done() const { return not m_reader; } private: @@ -104,8 +99,7 @@ public: void execute_single_command(CommandParameters params, Context& context, - const ShellContext& shell_context, - BufferCoord pos = {}); + const ShellContext& shell_context); Completions complete(const Context& context, CompletionFlags flags, |
