Skip to content

Commit

Permalink
Fix common prefix calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
nametoolong authored and adamcrown committed Jul 2, 2023
1 parent 3b956c7 commit c39e01c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/cache_crispies/json_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,13 @@ def write_attribute(json_writer, attribute)
private

def common_prefix_length(array1, array2)
(0...[array1.length, array2.length].min).each do |i|
shorter_length = [array1.length, array2.length].min

(0...shorter_length).each do |i|
return i if array1[i] != array2[i]
end

array1.length
shorter_length
end
end
end

0 comments on commit c39e01c

Please sign in to comment.