- return ipv4StringBits(str, str.length());
- }
-
- private static byte @NonNull[] ipv4StringBytes(final String str, final int limit) {
- final byte[] bytes = new byte[INET4_LENGTH];
- Ipv4Utils.fillIpv4Bytes(bytes, 0, str, 0, limit);
- return bytes;
- }
-
- private static int ipv4StringBits(final String str, final int limit) {
- int prev = 0;
- int current = 0;
- for (int i = 0, shift = 24; i < limit; ++i) {
- final char c = str.charAt(i);
- if (c == '.') {
- prev |= current << shift;
- shift -= 8;
- current = 0;
- } else {
- current = 10 * current + c - '0';
- }
- }
- return prev | current;