Skip to content

Commit

Permalink
issue #548: remove superstitious ||= {} since that is implied in the …
Browse files Browse the repository at this point in the history
…@tree hash
  • Loading branch information
ColinDKelley committed Jan 13, 2022
1 parent 098aec6 commit 8b66b47
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions lib/listen/record.rb
Expand Up @@ -19,7 +19,7 @@ def initialize(directory, silencer)

def add_dir(rel_path)
if !empty_dirname?(rel_path.to_s)
@tree[rel_path] ||= {}
@tree[rel_path.to_s]
end
end

Expand All @@ -36,10 +36,8 @@ def unset_path(rel_path)
def file_data(rel_path)
dirname, basename = Pathname(rel_path).split.map(&:to_s)
if empty_dirname?(dirname)
@tree[basename] ||= {}
@tree[basename].dup
else
@tree[dirname] ||= {}
@tree[dirname][basename] ||= {}
@tree[dirname][basename].dup
end
Expand Down Expand Up @@ -84,9 +82,8 @@ def reset_tree

def _fast_update_file(dirname, basename, data)
if empty_dirname?(dirname.to_s)
@tree[basename] = (@tree[basename] || {}).merge(data)
@tree[basename] = @tree[basename].merge(data)
else
@tree[dirname] ||= {}
@tree[dirname][basename] = (@tree[dirname][basename] || {}).merge(data)
end
end
Expand Down

0 comments on commit 8b66b47

Please sign in to comment.