diff options
author | Sven Gothel <[email protected]> | 2015-08-02 02:09:48 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2015-08-02 02:09:48 +0200 |
commit | fb970d92bc737afe34e23a0667b1737c6b105fde (patch) | |
tree | 292e9f38c8b57450ad7bafde7689ab3c4e1c3e47 /src/java/jogamp/common/util/Int32Bitfield.java | |
parent | bea171a16539b16b493acc9cc0e102985e2939a6 (diff) |
Fix Bitfield.put(..): Return previous value
Diffstat (limited to 'src/java/jogamp/common/util/Int32Bitfield.java')
-rw-r--r-- | src/java/jogamp/common/util/Int32Bitfield.java | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/java/jogamp/common/util/Int32Bitfield.java b/src/java/jogamp/common/util/Int32Bitfield.java index 9bf2117..7b55a59 100644 --- a/src/java/jogamp/common/util/Int32Bitfield.java +++ b/src/java/jogamp/common/util/Int32Bitfield.java @@ -115,14 +115,18 @@ public class Int32Bitfield implements Bitfield { return 0 != ( storage & ( 1 << bitnum ) ) ; } @Override - public final void put(final int bitnum, final boolean bit) throws IndexOutOfBoundsException { + public final boolean put(final int bitnum, final boolean bit) throws IndexOutOfBoundsException { check(UNIT_SIZE, bitnum); final int m = 1 << bitnum; - if( bit ) { - storage |= m; - } else { - storage &= ~m; + final boolean prev = 0 != ( storage & m ) ; + if( prev != bit ) { + if( bit ) { + storage |= m; + } else { + storage &= ~m; + } } + return prev; } @Override public final void set(final int bitnum) throws IndexOutOfBoundsException { |