Java: Optimize HashSet Initialization (#21205)

* Optimize HashSet Initialization

Noticed this while debugging - we can avoid wasting memory/cpu creating 16 buckets when we only need one or a few.

* generate samples

* use Arrays.asList
This commit is contained in:
Devon
2025-05-04 07:56:33 -07:00
committed by GitHub
parent 0389a99cec
commit 104ceb9c16
239 changed files with 488 additions and 1426 deletions

View File

@@ -124,11 +124,10 @@ public class OneOf1 {
static {
// a set of all properties/fields (JSON key names)
openapiFields = new HashSet<String>();
openapiFields.add("message1");
openapiFields = new HashSet<String>(Arrays.asList("message1"));
// a set of required properties/fields (JSON key names)
openapiRequiredFields = new HashSet<String>();
openapiRequiredFields = new HashSet<String>(0);
}
/**