Tiny improvements along the code

- less allocations (potentially)
This commit is contained in:
Igor Nikonov 2022-09-13 12:06:56 +00:00
parent 4d146b05a9
commit d8acb0e7ad
3 changed files with 7 additions and 6 deletions

View File

@ -623,6 +623,7 @@ NamesAndTypesList Block::getNamesAndTypesList() const
NamesAndTypes Block::getNamesAndTypes() const
{
NamesAndTypes res;
res.reserve(columns());
for (const auto & elem : data)
res.emplace_back(elem.name, elem.type);

View File

@ -418,7 +418,7 @@ void optimizeDuplicateDistinct(ASTSelectQuery & select)
return;
std::unordered_set<String> distinct_names = getDistinctNames(*subselect);
std::unordered_set<String> selected_names;
std::unordered_set<std::string_view> selected_names;
/// Check source column names from select list (ignore aliases and table names)
for (const auto & id : select.select()->children)
@ -427,11 +427,11 @@ void optimizeDuplicateDistinct(ASTSelectQuery & select)
if (!identifier)
return;
String name = identifier->shortName();
const String & name = identifier->shortName();
if (!distinct_names.contains(name))
return; /// Not a distinct column, keep DISTINCT for it.
selected_names.insert(name);
selected_names.emplace(name);
}
/// select columns list != distinct columns list

View File

@ -117,10 +117,10 @@ struct InputOrderInfo
* sort_description_for_merging will be equal to (c, d) and
* used_prefix_of_sorting_key_size will be equal to 4.
*/
size_t used_prefix_of_sorting_key_size;
const size_t used_prefix_of_sorting_key_size;
int direction;
UInt64 limit;
const int direction;
const UInt64 limit;
InputOrderInfo(
const SortDescription & sort_description_for_merging_,