-
Notifications
You must be signed in to change notification settings - Fork 294
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
internal/filetypes: speed up common case
Creating a `*build.File` value is somewhat expensive in the general case, but the general case is fairly unusual: it's much more common to have files interpreted according to their extension only with defaults for all other encoding attributes. Make this operation more efficient (no CUE value lookup required) for this common case by caching the resulting `*build.File` values for each of the known file extensions at init time. While we're about it, change the existing "common case" logic to use a check that matches the actual invariants of the common case for CUE: specifically the default encoding for CUE uses `form: ""` not `form: "schema"`: this makes a difference in subsequent CLs in the checks for whether a given parsed CUE file can be cached. Signed-off-by: Roger Peppe <[email protected]> Change-Id: I46f8c823cca08a44a09dece8d5e9a3df55bcf928 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1197557 Reviewed-by: Paul Jolly <[email protected]> TryBot-Result: CUEcueckoo <[email protected]> Unity-Result: CUE porcuepine <[email protected]>
- Loading branch information
Showing
3 changed files
with
40 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters