Skip to content

Commit

Permalink
Serialize MediaType as an integer to avoid string parsing
Browse files Browse the repository at this point in the history
Resolves opensearch-project#15979

Signed-off-by: Andrew Ross <andrross@amazon.com>
  • Loading branch information
andrross committed Sep 18, 2024
1 parent bd090d8 commit 0b760ab
Showing 1 changed file with 1 addition and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ public XContentBuilder contentBuilder(final OutputStream os) throws IOException
}
};

private int index;
private final int index;

XContentType(int index) {
this.index = index;
Expand All @@ -259,15 +259,6 @@ public String format() {
return subtype();
}

@Override
public void writeTo(StreamOutput output) throws IOException {
if (output.getVersion().onOrAfter(Version.V_3_0_0)) {
output.writeVInt(uniqueId());
} else {
output.writeString(this.mediaType());
}
}

@Override
public int uniqueId() {
return this.ordinal();
Expand Down

0 comments on commit 0b760ab

Please sign in to comment.