@@ -609,7 +609,7 @@ public Segment(int initialSize, int resizeThreshold) {
609609 * @param task the update operation
610610 * @return the result of the operation
611611 */
612- public <T > @ Nullable T doTask (final int hash , final @ Nullable Object key , final Task <T > task ) {
612+ private <T > @ Nullable T doTask (final int hash , final @ Nullable Object key , final Task <T > task ) {
613613 boolean resize = task .hasOption (TaskOption .RESIZE );
614614 if (task .hasOption (TaskOption .RESTRUCTURE_BEFORE )) {
615615 restructureIfNecessary (resize );
@@ -674,7 +674,6 @@ void restructureIfNecessary(boolean allowResize) {
674674 }
675675
676676 private void restructure (boolean allowResize , @ Nullable Reference <K , V > ref ) {
677- boolean needsResize ;
678677 lock ();
679678 try {
680679 int expectedCount = this .count .get ();
@@ -690,7 +689,7 @@ private void restructure(boolean allowResize, @Nullable Reference<K, V> ref) {
690689
691690 // Estimate new count, taking into account count inside lock and items that
692691 // will be purged.
693- needsResize = (expectedCount > 0 && expectedCount >= this .resizeThreshold );
692+ boolean needsResize = (expectedCount > 0 && expectedCount >= this .resizeThreshold );
694693 boolean resizing = false ;
695694 int restructureSize = this .references .length ;
696695 if (allowResize && needsResize && restructureSize < MAXIMUM_SEGMENT_SIZE ) {
@@ -731,8 +730,8 @@ private void restructure(boolean allowResize, @Nullable Reference<K, V> ref) {
731730 while (ref != null ) {
732731 if (!toPurge .contains (ref )) {
733732 Entry <K , V > entry = ref .get ();
734- // Also filter out null references that are now null
735- // they should be polled from the queue in a later restructure call.
733+ // Also filter out null references that are now null:
734+ // They should be polled from the queue in a later restructure call.
736735 if (entry != null ) {
737736 purgedRef = this .referenceManager .createReference (
738737 entry , ref .getHash (), purgedRef );
@@ -744,7 +743,7 @@ private void restructure(boolean allowResize, @Nullable Reference<K, V> ref) {
744743 this .references [i ] = purgedRef ;
745744 }
746745 }
747- this .count .set (Math . max ( newCount , 0 ) );
746+ this .count .set (newCount );
748747 }
749748 finally {
750749 unlock ();
0 commit comments