RegexLexer
binary search through the mappings to find the one that’s likely to actually work.
# File lib/rouge/lexers/viml.rb, line 72 def find_likely_mapping(mapping, word) min = 0 max = mapping.size until max == min mid = (max + min) / 2 cmp, _ = mapping[mid] case word <=> cmp when 1 # too low min = mid + 1 when -1 # too high max = mid when 0 # just right, abort! return mapping[mid] end end mapping[max - 1] end
Generated with the Darkfish Rdoc Generator 2.