forked from Baguette/dodb.cr
parent
f8e4e6c343
commit
c4223eabf1
|
@ -10,22 +10,15 @@ class DODB::Tags(V) < DODB::Indexer(V)
|
||||||
::Dir.mkdir_p indexing_directory
|
::Dir.mkdir_p indexing_directory
|
||||||
end
|
end
|
||||||
|
|
||||||
# FIXME: Too slow. That `uniq` call alone is a perf eater.
|
# FIXME: The slow is damn too high.
|
||||||
def tag_combinations(tags)
|
def tag_combinations(tags)
|
||||||
combinations = [] of Array(String)
|
combinations = [] of Array(String)
|
||||||
|
|
||||||
previous_tags = [] of String
|
tags.size.times do |i|
|
||||||
while tag = tags.shift?
|
combinations.concat tags.permutations (i+1)
|
||||||
previous_tags.push tag
|
|
||||||
|
|
||||||
combinations.push previous_tags.clone
|
|
||||||
|
|
||||||
if tags.size > 0
|
|
||||||
combinations.push tags.clone
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
combinations.uniq
|
return combinations
|
||||||
end
|
end
|
||||||
|
|
||||||
def index(key, value)
|
def index(key, value)
|
||||||
|
|
Loading…
Reference in New Issue