From c4223eabf1c50bfae3a7aff7f3ad046a5bbeecff Mon Sep 17 00:00:00 2001 From: Luka Vandervelden Date: Tue, 7 Apr 2020 23:29:29 +0200 Subject: [PATCH] Emergency fix for tags. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit They’ll work, but they’ll still be super slow. --- src/dodb/tags.cr | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/dodb/tags.cr b/src/dodb/tags.cr index 19e766b..f7b0e85 100644 --- a/src/dodb/tags.cr +++ b/src/dodb/tags.cr @@ -10,22 +10,15 @@ class DODB::Tags(V) < DODB::Indexer(V) ::Dir.mkdir_p indexing_directory end - # FIXME: Too slow. That `uniq` call alone is a perf eater. + # FIXME: The slow is damn too high. def tag_combinations(tags) combinations = [] of Array(String) - previous_tags = [] of String - while tag = tags.shift? - previous_tags.push tag - - combinations.push previous_tags.clone - - if tags.size > 0 - combinations.push tags.clone - end + tags.size.times do |i| + combinations.concat tags.permutations (i+1) end - combinations.uniq + return combinations end def index(key, value)