MCPcopy Index your code
hub / github.com/apache/tomcat / getRealIndex

Method getRealIndex

java/org/apache/coyote/http2/HpackDecoder.java:302–312  ·  view source on GitHub ↗

because we use a ring buffer type construct, and don't actually shuffle items in the array, we need to figure out the real index to use. package private for unit tests @param index The index from the hpack @return the real index into the array

(int index)

Source from the content-addressed store, hash-verified

300 * @return the real index into the array
301 */
302 int getRealIndex(int index) throws HpackException {
303 int dynamicIndex = index - Hpack.STATIC_TABLE_LENGTH;
304 // The index is one based, but our table is zero based
305 // Also, because of our ring buffer set up, the indexes are reversed
306 // index = 1 is at position firstSlotPosition + filledSlots
307 if (dynamicIndex < 1 || dynamicIndex > filledTableSlots) {
308 throw new HpackException(sm.getString("hpackdecoder.headerTableIndexInvalid", Integer.valueOf(index),
309 Integer.valueOf(Hpack.STATIC_TABLE_LENGTH), Integer.valueOf(filledTableSlots)));
310 }
311 return (firstSlotPosition + (filledTableSlots - dynamicIndex)) % headerTable.length;
312 }
313
314 private void addStaticTableEntry(int index) throws HpackException {
315 // adds an entry from the static table.

Callers 2

handleIndexMethod · 0.95

Calls 2

getStringMethod · 0.65
valueOfMethod · 0.45

Tested by

no test coverage detected