Permalink
Browse files

Changed IPAddress.parse() to improve speed (see new wiki benchmark page)

  • Loading branch information...
1 parent 96aaf68 commit 10c9350c941ba49d91d01c6fe4074551d9fe4c32 @bluemonk bluemonk committed May 24, 2011
Showing with 5 additions and 1 deletion.
  1. +5 −1 lib/ipaddress.rb
View
6 lib/ipaddress.rb
@@ -43,8 +43,12 @@ def IPAddress::parse(str)
case str
when /:.+\./
IPAddress::IPv6::Mapped.new(str)
+ when /\./
+ IPAddress::IPv4.new(str)
+ when /:/
+ IPAddress::IPv6.new(str)
else
- IPAddress::IPv4.new(str) rescue IPAddress::IPv6.new(str)
+ raise ArgumentError, "Unknown IP Address #{str}"
end
end

0 comments on commit 10c9350

Please sign in to comment.