Skip to content

repeated parsing of file directories by every getImage call #449

Open
@jcphill

Description

@jcphill

As shown below, every call to getImage() calls await this.parseFileDirectoriesPerFile() without using the result. parseFileDirectoriesPerFile() saves the result in this.fileDirectoriesPerFile but that variable is never referenced. The result is that every call to getImage() calls parseFileDirectoryAt() for every file for no reason.

geotiff.js/src/geotiff.js

Lines 613 to 634 in af0421b

this.fileDirectoriesPerFile = null;
this.fileDirectoriesPerFileParsing = null;
this.imageCount = null;
}
async parseFileDirectoriesPerFile() {
const requests = [this.mainFile.parseFileDirectoryAt(this.mainFile.firstIFDOffset)]
.concat(this.overviewFiles.map((file) => file.parseFileDirectoryAt(file.firstIFDOffset)));
this.fileDirectoriesPerFile = await Promise.all(requests);
return this.fileDirectoriesPerFile;
}
/**
* Get the n-th internal subfile of an image. By default, the first is returned.
*
* @param {number} [index=0] the index of the image to return.
* @returns {Promise<GeoTIFFImage>} the image at the given index
*/
async getImage(index = 0) {
await this.getImageCount();
await this.parseFileDirectoriesPerFile();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions