Ensure the chunk size is a multiple of the alignment, closed https://github.com/OpenHFT/Chronicle-Map/issues/169

This commit is contained in:
Peter Lawrey
2019-05-09 12:28:04 +01:00
parent a165c357d1
commit 1a36f1bbc6
4 changed files with 37 additions and 14 deletions
+2 -2
View File
@@ -708,8 +708,8 @@ public abstract class VanillaChronicleHash<K,
// int division is MUCH faster than long on Intel CPUs
if (sizeInBytes <= Integer.MAX_VALUE)
return (((int) sizeInBytes) / (int) chunkSize) + 1;
return (int) (sizeInBytes / chunkSize) + 1;
return (int) (sizeInBytes + chunkSize - 1) / (int) chunkSize;
return Math.toIntExact((sizeInBytes + chunkSize - 1) / chunkSize);
}
public final int size() {