diff --git a/inst/include/dplyr/Result/Count_Distinct.h b/inst/include/dplyr/Result/Count_Distinct.h index b5913ea27f..c2be326dc2 100644 --- a/inst/include/dplyr/Result/Count_Distinct.h +++ b/inst/include/dplyr/Result/Count_Distinct.h @@ -17,11 +17,12 @@ namespace dplyr { typedef dplyr_hash_set Set; Count_Distinct(Visitor v_): - v(v_), set(1024, Hash(v), Pred(v)) + v(v_), set(0, Hash(v), Pred(v)) {} inline int process_chunk(const SlicingIndex& indices) { set.clear(); + set.rehash(indices.size()); int n = indices.size(); for (int i=0; i Set; Count_Distinct_Narm(Visitor v_): - v(v_), set(1024, Hash(v), Pred(v)) + v(v_), set(0, Hash(v), Pred(v)) {} inline int process_chunk(const SlicingIndex& indices) { set.clear(); + set.rehash(indices.size()); int n = indices.size(); for (int i=0; i Vec; typedef typename Rcpp::traits::storage_type::type STORAGE; - In(Vec data_, Vec table_) : + In(Vec data_, const Vec& table_) : data(data_), - table(table_), - set(table.begin(), table.end()) + set(table_.begin(), table_.end()) {} void process_slice(LogicalVector& out, const SlicingIndex& index, const SlicingIndex& out_index) { @@ -32,7 +31,7 @@ namespace dplyr { } private: - Vec data, table; + Vec data; dplyr_hash_set set; }; diff --git a/src/api.cpp b/src/api.cpp index 611bbe8d44..006afe3148 100644 --- a/src/api.cpp +++ b/src/api.cpp @@ -293,7 +293,7 @@ namespace dplyr { CharacterVectorOrderer::CharacterVectorOrderer(const CharacterVector& data_) : data(data_), - set(), + set(data.size()), orders(no_init(data.size())) { int n = data.size();