Skip to content

Commit 15a5e0f

Browse files
authored
Avoid expansion of bit set (helidon-io#11389)
1 parent bfbc230 commit 15a5e0f

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

http/http/src/main/java/io/helidon/http/HeadersImpl.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2022, 2025 Oracle and/or its affiliates.
2+
* Copyright (c) 2022, 2026 Oracle and/or its affiliates.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -31,14 +31,17 @@
3131
@SuppressWarnings("unchecked")
3232
class HeadersImpl<T extends WritableHeaders<T>> implements WritableHeaders<T> {
3333
static final int KNOWN_HEADER_SIZE = HeaderNameEnum.values().length;
34+
// must be one higher to avoid bit set expansion
35+
private static final int NBITS = KNOWN_HEADER_SIZE + 1;
36+
3437
/*
3538
Optimization for most commonly used header names
3639
*/
3740
private final Header[] knownHeaders = new Header[KNOWN_HEADER_SIZE];
3841

3942
// custom (unknown) headers are slower
4043
private Map<HeaderName, Header> customHeaders = null;
41-
private final BitSet knownHeaderIndices = new BitSet(KNOWN_HEADER_SIZE);
44+
private final BitSet knownHeaderIndices = new BitSet(NBITS);
4245

4346
HeadersImpl() {
4447
}

0 commit comments

Comments
 (0)