Revision: 19769
http://sourceforge.net/p/gate/code/19769
Author: markagreenwood
Date: 2016-11-22 11:59:24 +0000 (Tue, 22 Nov 2016)
Log Message:
-----------
minor code improvements
Modified Paths:
--------------
gate/branches/sawdust2/plugins/JAPE_Plus/src/main/java/gate/jape/plus/SPTBase.java
Modified:
gate/branches/sawdust2/plugins/JAPE_Plus/src/main/java/gate/jape/plus/SPTBase.java
===================================================================
---
gate/branches/sawdust2/plugins/JAPE_Plus/src/main/java/gate/jape/plus/SPTBase.java
2016-11-22 08:07:02 UTC (rev 19768)
+++
gate/branches/sawdust2/plugins/JAPE_Plus/src/main/java/gate/jape/plus/SPTBase.java
2016-11-22 11:59:24 UTC (rev 19769)
@@ -661,7 +661,9 @@
protected static int binarySearchFromTo(int[] array, int from, int to,
IntComparator comp) {
final int key = 0;
while (from <= to) {
- int mid = (from + to) / 2;
+ //with really large arrays this could overflow
+ //int mid = (from + to) / 2;
+ int mid = (from + to) >>> 1;
int comparison = comp.compare(array[mid], array[key]);
if (comparison < 0) from = mid + 1;
else if (comparison > 0) to = mid - 1;
@@ -692,7 +694,9 @@
int from = idx;
int to = annotation.length -1;
while(from <= to) {
- int mid = (from + to) / 2;
+ //with large arrays this could overflow
+ //int mid = (from + to) / 2;
+ int mid = ( from + to) >>> 1;
long midStartOffset = annotation[mid].getStartNode().getOffset();
if(midStartOffset > endOffset) {
// move to the left
@@ -839,7 +843,7 @@
} else if(predicate.featureValue instanceof Long) {
if(!(actualValue instanceof Long)) {
try {
- actualValue = new Long(actualValue.toString());
+ actualValue = Long.valueOf(actualValue.toString());
} catch(NumberFormatException e) {
logger.warn("Could not convert value \"" + actualValue.toString()
+ "\" of feature \"" + predicate.annotationAccessor
@@ -851,7 +855,7 @@
} else if(predicate.featureValue instanceof Double) {
if(!(actualValue instanceof Double)) {
try {
- actualValue = new Double(actualValue.toString());
+ actualValue = Double.valueOf(actualValue.toString());
} catch(NumberFormatException e) {
logger.warn("Could not convert value \"" + actualValue.toString()
+ "\" of feature \"" + predicate.annotationAccessor
@@ -1138,8 +1142,8 @@
// (a rule with only a Kleene* can legitimately match nothing,
leading
// to an infinite loop)
if(currentAnnotation != Integer.MAX_VALUE &&
- annotation[oldCurrAnn].getStartNode().getOffset() ==
- annotation[currentAnnotation].getStartNode().getOffset()) {
+ annotation[oldCurrAnn].getStartNode().getOffset().equals(
+ annotation[currentAnnotation].getStartNode().getOffset())) {
// move to the next relevant offset in the input
currentAnnotation = annotationNextOffset[currentAnnotation];
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs