clcron / guava-libraries

Automatically exported from code.google.com/p/guava-libraries
Apache License 2.0
1 stars 0 forks source link

InetAddresses.textToNumericFormatV4(): Performance improvement possible? #559

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The first check in this method is ipString.contains(":"). I suspect that (I 
have no statistics to back it up), this test would only very rarely be true 
(returning null). Hence, since contains() is O(N) (as is split()), I suggest 
that this test be removed. In cases where the string actually contains ":" the 
method will fail anyway with a NumberFormatException and return null as 
expected (same behavior).

Original issue reported on code.google.com by hein.mel...@gmail.com on 24 Feb 2011 at 8:23

GoogleCodeExporter commented 9 years ago
It is true that a linear search has O(n) but consider the tiny size of an 
IP-address-string. So I think the linear search is a non-issue. But if there is 
a “:” in the string then the exception handing is more expensive. This 
solution has acceptable performance on both use cases. There are more serious 
performance issues in the Google Libraries of O(M*N) ...

Original comment by ullenb...@googlemail.com on 24 Feb 2011 at 9:24

GoogleCodeExporter commented 9 years ago
We might spend more time benchmarking this in the future.

Original comment by kevinb@google.com on 16 Jul 2011 at 8:13

GoogleCodeExporter commented 9 years ago
This issue has been migrated to GitHub.

It can be found at https://github.com/google/guava/issues/<id>

Original comment by cgdecker@google.com on 1 Nov 2014 at 4:15

GoogleCodeExporter commented 9 years ago

Original comment by cgdecker@google.com on 3 Nov 2014 at 9:09