mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8225339: Optimize HashMap.keySet()/HashMap.values()/HashSet toArray() methods
Reviewed-by: rriggs, redestad, smarks
This commit is contained in:
parent
51cf24fcc0
commit
822c02437a
5 changed files with 387 additions and 3 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -358,4 +358,14 @@ public class HashSet<E>
|
|||
public Spliterator<E> spliterator() {
|
||||
return new HashMap.KeySpliterator<>(map, 0, -1, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] toArray() {
|
||||
return map.keysToArray(new Object[map.size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T[] toArray(T[] a) {
|
||||
return map.keysToArray(map.prepareArray(a));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue