Skip to content

Commit cb116be

Browse files
committedMar 6, 2015
Merge pull request #15 from niqueco/fix-for-old-androids
don't use Arrays.copyOf to get compatibility with Android <2.3
2 parents 0b4c69c + 0c68fe1 commit cb116be

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed
 

Diff for: ‎src/main/java/com/github/davidmoten/geo/CoverageLongs.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ public CoverageLongs(long[] hashes, int count, double ratio) {
4545
* @return set of hashes
4646
*/
4747
public long[] getHashes() {
48-
return Arrays.copyOf(hashes, count);
48+
long[] res = new long[count];
49+
System.arraycopy(hashes, 0, res, 0, count);
50+
return res;
4951
}
5052

5153
/**

Diff for: ‎src/main/java/com/github/davidmoten/geo/GeoHash.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -626,8 +626,11 @@ void add(long l)
626626
for(int i = 0 ; i < count ; i++)
627627
if(array[i] == l)
628628
return;
629-
if(count == cap)
630-
array = Arrays.copyOf(array, cap*=2);
629+
if(count == cap) {
630+
long[] newArray = new long[cap*=2];
631+
System.arraycopy(array, 0, newArray, 0, count);
632+
array = newArray;
633+
}
631634
array[count++] = l;
632635
}
633636
}

0 commit comments

Comments
 (0)
Failed to load comments.