Skip to content

Commit 947895a

Browse files
committed
Make resizing the SimHash coefficient array more memory-efficient. Fixes issue #12.
1 parent 3dd7d56 commit 947895a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/hashes/simhash.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,9 @@ function Base.resize!(hashfn::SimHash, n :: Integer)
9797

9898
# Generate new coefficients in the empty entries
9999
if n > old_n
100-
# TODO: implement with map! to reduce memory allocation
101-
@views new_coeff[old_n+1:end,1:end] = randn(n - old_n, n_hashes)
100+
@views map!(_ -> randn(),
101+
new_coeff[old_n+1:end,1:end],
102+
new_coeff[old_n+1:end,1:end])
102103
end
103104

104105
hashfn.coeff = new_coeff

0 commit comments

Comments
 (0)