Add strip_prefix
Method Based on Longest Match to ZeroTrie
#4379
Labels
A-performance
Area: Performance (CPU, Memory)
In the
experimental/unitsconversion/src/measureunit.rs
file, we have aget_unit_id
function that searches for an item in aZeroTrie
in an inefficient way. The current implementation iterates over each character in the string, creating a new identifier at each step and checking if it exists in the trie. This approach is not optimal.To improve this, we propose adding a strip_prefix method to the ZeroTrie struct. This method should return the longest matching prefix in the trie and the remaining part of the string (returning the remaining part is optional).
The implementation of
strip_prefix
should be by searching in the try without needing to create new id/part for each iteration.The text was updated successfully, but these errors were encountered: