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

Comparing jsr166/src/main/java/util/HashMap.java (file contents):
Revision 1.3 by jsr166, Sun Oct 22 17:44:03 2017 UTC vs.
Revision 1.5 by jsr166, Tue May 22 16:16:57 2018 UTC

# Line 1 | Line 1
1   /*
2 < * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
2 > * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
3   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4   *
5   * This code is free software; you can redistribute it and/or modify it
# Line 376 | Line 376 | public class HashMap<K,V> extends Abstra
376       * Returns a power of two size for the given target capacity.
377       */
378      static final int tableSizeFor(int cap) {
379 <        int n = cap - 1;
380 <        n |= n >>> 1;
381 <        n |= n >>> 2;
382 <        n |= n >>> 4;
383 <        n |= n >>> 8;
384 <        n |= n >>> 16;
379 >        int n = -1 >>> Integer.numberOfLeadingZeros(cap - 1);
380          return (n < 0) ? 1 : (n >= MAXIMUM_CAPACITY) ? MAXIMUM_CAPACITY : n + 1;
381      }
382  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines