You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by dw...@apache.org on 2020/04/13 11:37:40 UTC
[lucene-solr] branch master updated: Do a bit count on 8 bytes from
a long directly instead of reading 8 bytes from the reader. Byte order
doesn't matter here. (#1426)
This is an automated email from the ASF dual-hosted git repository.
dweiss pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
The following commit(s) were added to refs/heads/master by this push:
new 616ec98 Do a bit count on 8 bytes from a long directly instead of reading 8 bytes from the reader. Byte order doesn't matter here. (#1426)
616ec98 is described below
commit 616ec987a9d551e4c606de6d2998e990d0c68643
Author: Dawid Weiss <da...@carrotsearch.com>
AuthorDate: Mon Apr 13 13:37:25 2020 +0200
Do a bit count on 8 bytes from a long directly instead of reading 8 bytes from the reader. Byte order doesn't matter here. (#1426)
---
.../src/java/org/apache/lucene/util/fst/BitTableUtil.java | 15 ++++-----------
1 file changed, 4 insertions(+), 11 deletions(-)
diff --git a/lucene/core/src/java/org/apache/lucene/util/fst/BitTableUtil.java b/lucene/core/src/java/org/apache/lucene/util/fst/BitTableUtil.java
index ee59cd4..89ef06a 100644
--- a/lucene/core/src/java/org/apache/lucene/util/fst/BitTableUtil.java
+++ b/lucene/core/src/java/org/apache/lucene/util/fst/BitTableUtil.java
@@ -52,7 +52,7 @@ class BitTableUtil {
int bitCount = 0;
for (int i = bitTableBytes >> 3; i > 0; i--) {
// Count the bits set for all plain longs.
- bitCount += Long.bitCount(read8Bytes(reader));
+ bitCount += bitCount8Bytes(reader);
}
int numRemainingBytes;
if ((numRemainingBytes = bitTableBytes & (Long.BYTES - 1)) != 0) {
@@ -75,7 +75,7 @@ class BitTableUtil {
int bitCount = 0;
for (int i = bitIndex >> 6; i > 0; i--) {
// Count the bits set for all plain longs.
- bitCount += Long.bitCount(read8Bytes(reader));
+ bitCount += bitCount8Bytes(reader);
}
int remainingBits;
if ((remainingBits = bitIndex & (Long.SIZE - 1)) != 0) {
@@ -166,14 +166,7 @@ class BitTableUtil {
return l;
}
- private static long read8Bytes(FST.BytesReader reader) throws IOException {
- return readByte(reader)
- | readByte(reader) << 8
- | readByte(reader) << 16
- | readByte(reader) << 24
- | readByte(reader) << 32
- | readByte(reader) << 40
- | readByte(reader) << 48
- | readByte(reader) << 56;
+ private static int bitCount8Bytes(FST.BytesReader reader) throws IOException {
+ return Long.bitCount(reader.readLong());
}
}
\ No newline at end of file