maxmind/geoip-api-java

Expose 'bytesToLong(byte[])' as public utility method in LookupService

Closed this issue · 1 comments

Each lookup in LookupService involves creating an InetAddress, copying its byte[] content via a getAddress() call and passing this copied byte array to bytesToLong(byte[]) hash function. We resolve both geographical location and ISP details for each IP which means 2 separate lookups (these are as you know 2 separate databases). These are expensive and wasteful transformation in our experience. By exposing bytesToLong(byte[]) we could at least make sure that these transformations happen only once per IP address (and not per database lookup).

I would be quite surprised if the bit operations in that function were causing any noticeable slowdown. Do you have any profiling data to support this?