Replace certain uses of 'gsub' with 'tr' or 'chomp' for a speed

improvement
This commit is contained in:
James Cook
2016-06-10 21:37:33 -05:00
parent d1c5949922
commit c0e25b5a9a
9 changed files with 15 additions and 16 deletions

View File

@@ -16,7 +16,7 @@ class IPAddr
(4 - parts.size).times { parts << '*' } # support strings like 192.*
v = parts.join('.')
"#{v.gsub('*', '0')}/#{32 - (v.count('*') * 8)}"
"#{v.tr('*', '0')}/#{32 - (v.count('*') * 8)}"
end
def to_cidr_s