From aaf4ec62cf02f0c14f3b8ff49de118d9a899e463 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 29 Oct 2020 22:25:41 +0100 Subject: LanguageServers/Cpp: Avoid some unnecessary vector copies --- DevTools/HackStudio/LanguageServers/Cpp/AutoComplete.cpp | 8 ++++---- DevTools/HackStudio/LanguageServers/Cpp/AutoComplete.h | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'DevTools/HackStudio') diff --git a/DevTools/HackStudio/LanguageServers/Cpp/AutoComplete.cpp b/DevTools/HackStudio/LanguageServers/Cpp/AutoComplete.cpp index d09c96cd58..c56000fb19 100644 --- a/DevTools/HackStudio/LanguageServers/Cpp/AutoComplete.cpp +++ b/DevTools/HackStudio/LanguageServers/Cpp/AutoComplete.cpp @@ -32,7 +32,7 @@ namespace LanguageServers::Cpp { -Vector AutoComplete::get_suggestions(const String& code, GUI::TextPosition autocomplete_position) +Vector AutoComplete::get_suggestions(const String& code, const GUI::TextPosition& autocomplete_position) { auto lines = code.split('\n', true); Lexer lexer(code); @@ -53,12 +53,12 @@ Vector AutoComplete::get_suggestions(const String& code, G return suggestions; } -String AutoComplete::text_of_token(const Vector lines, const Cpp::Token& token) +String AutoComplete::text_of_token(const Vector& lines, const Cpp::Token& token) { return lines[token.m_start.line].substring(token.m_start.column, token.m_end.column - token.m_start.column + 1); } -Optional AutoComplete::token_in_position(const Vector& tokens, GUI::TextPosition position) +Optional AutoComplete::token_in_position(const Vector& tokens, const GUI::TextPosition& position) { for (size_t token_index = 0; token_index < tokens.size(); ++token_index) { auto& token = tokens[token_index]; @@ -71,7 +71,7 @@ Optional AutoComplete::token_in_position(const Vector& token return {}; } -Vector AutoComplete::identifier_prefixes(const Vector lines, const Vector& tokens, size_t target_token_index) +Vector AutoComplete::identifier_prefixes(const Vector& lines, const Vector& tokens, size_t target_token_index) { auto partial_input = text_of_token(lines, tokens[target_token_index]); Vector suggestions; diff --git a/DevTools/HackStudio/LanguageServers/Cpp/AutoComplete.h b/DevTools/HackStudio/LanguageServers/Cpp/AutoComplete.h index d0b772b0ad..0ee328b5b7 100644 --- a/DevTools/HackStudio/LanguageServers/Cpp/AutoComplete.h +++ b/DevTools/HackStudio/LanguageServers/Cpp/AutoComplete.h @@ -41,12 +41,12 @@ class AutoComplete { public: AutoComplete() = delete; - static Vector get_suggestions(const String& code, GUI::TextPosition autocomplete_position); + static Vector get_suggestions(const String& code, const GUI::TextPosition& autocomplete_position); private: - static Optional token_in_position(const Vector&, GUI::TextPosition); - static String text_of_token(const Vector lines, const Cpp::Token&); - static Vector identifier_prefixes(const Vector lines, const Vector&, size_t target_token_index); + static Optional token_in_position(const Vector&, const GUI::TextPosition&); + static String text_of_token(const Vector& lines, const Cpp::Token&); + static Vector identifier_prefixes(const Vector& lines, const Vector&, size_t target_token_index); }; } -- cgit v1.2.3