ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/jsr166e/LongAdder.java
(Generate patch)

Comparing jsr166/src/jsr166e/LongAdder.java (file contents):
Revision 1.5 by dl, Tue Aug 2 18:04:12 2011 UTC vs.
Revision 1.6 by dl, Sun Aug 28 19:08:07 2011 UTC

# Line 92 | Line 92 | public class LongAdder extends Striped64
92       * @return the sum
93       */
94      public long sum() {
95        Cell[] as = cells;
95          long sum = base;
96 +        Cell[] as = cells;
97          if (as != null) {
98              int n = as.length;
99              for (int i = 0; i < n; ++i) {
# Line 127 | Line 127 | public class LongAdder extends Striped64
127       * @return the sum
128       */
129      public long sumThenReset() {
130        Cell[] as = cells;
130          long sum = base;
131 +        Cell[] as = cells;
132          base = 0L;
133          if (as != null) {
134              int n = as.length;
135              for (int i = 0; i < n; ++i) {
136                  Cell a = as[i];
137                  if (a != null) {
138 <                    long v = a.value;
138 >                    sum += a.value;
139                      a.value = 0L;
140                    sum += v;
140                  }
141              }
142          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines