aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAxel Howind <axh@apache.org>2020-02-20 15:04:57 +0000
committerAxel Howind <axh@apache.org>2020-02-20 15:04:57 +0000
commit09d55c783206a798f7b77d9c91182f7e6c55e1a3 (patch)
tree0d8cfadb3d5972719239b847f278d265018f622d
parentbc969fe4aa27bfb7d044e2ae4588f74754d45f6d (diff)
downloadpoi-09d55c783206a798f7b77d9c91182f7e6c55e1a3.tar.gz
poi-09d55c783206a798f7b77d9c91182f7e6c55e1a3.zip
Applied "clean up IntList code" patch from bug 63805
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1874257 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--src/java/org/apache/poi/util/IntList.java84
1 files changed, 34 insertions, 50 deletions
diff --git a/src/java/org/apache/poi/util/IntList.java b/src/java/org/apache/poi/util/IntList.java
index 9687d2fab2..03571bf953 100644
--- a/src/java/org/apache/poi/util/IntList.java
+++ b/src/java/org/apache/poi/util/IntList.java
@@ -100,7 +100,6 @@ public class IntList
}
else
{
-
// index < limit -- insert into the middle
if (_limit == _array.length)
{
@@ -229,16 +228,14 @@ public class IntList
public boolean contains(final int o)
{
- boolean rval = false;
-
- for (int j = 0; !rval && (j < _limit); j++)
+ for (int j = 0; j < _limit; j++)
{
if (_array[ j ] == o)
{
- rval = true;
+ return true;
}
}
- return rval;
+ return false;
}
/**
@@ -253,19 +250,17 @@ public class IntList
public boolean containsAll(final IntList c)
{
- boolean rval = true;
-
if (this != c)
{
- for (int j = 0; rval && (j < c._limit); j++)
+ for (int j = 0; j < c._limit; j++)
{
if (!contains(c._array[ j ]))
{
- rval = false;
+ return false;
}
}
}
- return rval;
+ return true;
}
/**
@@ -286,24 +281,27 @@ public class IntList
public boolean equals(final Object o)
{
- boolean rval = this == o;
-
- if (!rval && (o != null) && (o.getClass() == this.getClass()))
- {
- IntList other = ( IntList ) o;
+ if (o == this) {
+ return true;
+ }
+
+ if (o.getClass()!=this.getClass()) {
+ return false;
+ }
- if (other._limit == _limit)
- {
+ IntList other = ( IntList ) o;
- // assume match
- rval = true;
- for (int j = 0; rval && (j < _limit); j++)
- {
- rval = _array[ j ] == other._array[ j ];
- }
+ if (other._limit != _limit) {
+ return false;
+ }
+
+ for (int i=0; i< _limit; i++) {
+ if (other._array[i] != _array[i]) {
+ return false;
}
}
- return rval;
+
+ return true;
}
/**
@@ -374,20 +372,12 @@ public class IntList
public int indexOf(final int o)
{
- int rval = 0;
-
- for (; rval < _limit; rval++)
- {
- if (o == _array[ rval ])
- {
- break;
+ for (int i=0; i<_limit; i++) {
+ if (_array[i] == o) {
+ return i;
}
}
- if (rval == _limit)
- {
- rval = -1; // didn't find it
- }
- return rval;
+ return -1;
}
/**
@@ -416,16 +406,12 @@ public class IntList
public int lastIndexOf(final int o)
{
- int rval = _limit - 1;
-
- for (; rval >= 0; rval--)
- {
- if (o == _array[ rval ])
- {
- break;
+ for (int i=_limit-1; i>=0; i--) {
+ if (_array[i] == o) {
+ return i;
}
}
- return rval;
+ return -1;
}
/**
@@ -469,9 +455,7 @@ public class IntList
public boolean removeValue(final int o)
{
- boolean rval = false;
-
- for (int j = 0; !rval && (j < _limit); j++)
+ for (int j = 0; j < _limit; j++)
{
if (o == _array[ j ])
{
@@ -479,10 +463,10 @@ public class IntList
System.arraycopy(_array, j + 1, _array, j, _limit - j);
}
_limit--;
- rval = true;
+ return true;
}
}
- return rval;
+ return false;
}
/**