Skip to content

Commit

Permalink
Optimize the JSON parsing in NpmPackageIndexBuilder.seeFile
Browse files Browse the repository at this point in the history
  • Loading branch information
qligier committed Feb 6, 2025
1 parent ec8d461 commit c3603d3
Showing 1 changed file with 1 addition and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,9 @@ public void start(String filename) {

public boolean seeFile(String name, byte[] content) {
if (name.endsWith(".json")) {
/* We are only interested in some String fields on the first level of the JSON file.
/* We are only interested in some string fields on the first level of the JSON file.
* We can then use a streaming parser to get the values of these fields instead of parsing the whole file and
* allocating memory for everything in it.
* The key 'resourceType' should happen before all other keys, but in R4B, there are resources where it's not
* the case.
*/
try (final var parser = new JsonFactory().createParser(content)) {
final var fi = new JsonObject();
Expand Down

0 comments on commit c3603d3

Please sign in to comment.