From d7c0af3f30e62e34c63c12678b223735449b9e6f Mon Sep 17 00:00:00 2001 From: Yonik Seeley Date: Fri, 6 Jul 2007 16:34:40 +0000 Subject: [PATCH] replace div with shift since idiv takes ~40 cycles and compiler can't do strength reduction w/o knowing ops are non-negative git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@553947 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/lucene/index/DocumentWriter.java | 2 +- .../org/apache/lucene/index/DocumentsWriter.java | 12 ++++++------ src/java/org/apache/lucene/index/FieldsReader.java | 2 +- .../org/apache/lucene/index/TermVectorsReader.java | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/java/org/apache/lucene/index/DocumentWriter.java b/src/java/org/apache/lucene/index/DocumentWriter.java index d95bf7fbe6f..4cb201361ed 100644 --- a/src/java/org/apache/lucene/index/DocumentWriter.java +++ b/src/java/org/apache/lucene/index/DocumentWriter.java @@ -323,7 +323,7 @@ final class DocumentWriter { if (lo >= hi) return; - int mid = (lo + hi) / 2; + int mid = (lo + hi) >>> 1; if (postings[lo].term.compareTo(postings[mid].term) > 0) { Posting tmp = postings[lo]; diff --git a/src/java/org/apache/lucene/index/DocumentsWriter.java b/src/java/org/apache/lucene/index/DocumentsWriter.java index c7083ee0b49..450d1cb37b7 100644 --- a/src/java/org/apache/lucene/index/DocumentsWriter.java +++ b/src/java/org/apache/lucene/index/DocumentsWriter.java @@ -734,7 +734,7 @@ final class DocumentsWriter { if (lo >= hi) return; - int mid = (lo + hi) / 2; + int mid = (lo + hi) >>> 1; if (comparePostings(postings[lo], postings[mid]) > 0) { Posting tmp = postings[lo]; @@ -792,7 +792,7 @@ final class DocumentsWriter { if (lo >= hi) return; - int mid = (lo + hi) / 2; + int mid = (lo + hi) >>> 1; if (comparePostings(postings[lo].p, postings[mid].p) > 0) { PostingVector tmp = postings[lo]; @@ -880,9 +880,9 @@ final class DocumentsWriter { int hashSize = fp.postingsHashSize; // Reduce hash so it's between 25-50% full - while (fp.numPostings < hashSize/2 && hashSize >= 2) - hashSize /= 2; - hashSize *= 2; + while (fp.numPostings < (hashSize>>1) && hashSize >= 2) + hashSize >>= 1; + hashSize <<= 1; if (hashSize != fp.postingsHash.length) fp.rehashPostings(hashSize); @@ -1598,7 +1598,7 @@ final class DocumentsWriter { postingsHash = newHash; postingsHashSize = newSize; - postingsHashHalfSize = newSize/2; + postingsHashHalfSize = newSize >> 1; } final ByteSliceReader vectorSliceReader = new ByteSliceReader(); diff --git a/src/java/org/apache/lucene/index/FieldsReader.java b/src/java/org/apache/lucene/index/FieldsReader.java index c36bbcc978e..cd0c7e1c34f 100644 --- a/src/java/org/apache/lucene/index/FieldsReader.java +++ b/src/java/org/apache/lucene/index/FieldsReader.java @@ -82,7 +82,7 @@ final class FieldsReader { assert ((int) (indexStream.length()/8)) >= size + this.docStoreOffset; } else { this.docStoreOffset = 0; - this.size = (int) (indexStream.length() / 8); + this.size = (int) (indexStream.length() >> 3); } } diff --git a/src/java/org/apache/lucene/index/TermVectorsReader.java b/src/java/org/apache/lucene/index/TermVectorsReader.java index a0eeeed2874..a03a729802b 100644 --- a/src/java/org/apache/lucene/index/TermVectorsReader.java +++ b/src/java/org/apache/lucene/index/TermVectorsReader.java @@ -62,7 +62,7 @@ class TermVectorsReader implements Cloneable { tvfFormat = checkValidFormat(tvf); if (-1 == docStoreOffset) { this.docStoreOffset = 0; - this.size = (int) (tvx.length() / 8); + this.size = (int) (tvx.length() >> 3); } else { this.docStoreOffset = docStoreOffset; this.size = size;