Skip to content

Commit

Permalink
string.cr: couple of review fixes in rabin-karp optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
funny-falcon committed Apr 18, 2024
1 parent 962a4b1 commit c7faf09
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/string.cr
Original file line number Diff line number Diff line change
Expand Up @@ -3412,9 +3412,9 @@ class String

if search.bytesize <= 8
search_bytesize = search.bytesize
return index_short(UInt64, char_index, pointer, end_pointer, search) { |pointer|
return index_short(UInt64, char_index, pointer, end_pointer, search) do |pointer|
String.char_bytesize_at(pointer - search_bytesize)
}
end
end

head_pointer = pointer
Expand Down Expand Up @@ -3804,9 +3804,7 @@ class String
return if pointer >= end_pointer

# update a rolling hash of this text (haystack)
hash = hash &* PRIME_RK &+ pointer.value &- pow &* head_pointer.value
pointer += 1
head_pointer += 1
update_hash 1
offset += 1
end

Expand Down

0 comments on commit c7faf09

Please sign in to comment.