Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cue/load: avoid one stat call when loading a valid module
We would first stat cue.mod to see whether it is a regular file, to give a clear human-friendly error, and then open cue.mod/module.cue to actually parse the module file declaring the module to be loaded. In most cases, cue.mod is a directory, so we can open cue.mod/module.cue directly and a nil error already tells us that cue.mod is a directory. Only stat cue.mod if the cue.mod/module.cue file open fails. This reduces one syscall when loading a valid module, which isn't much, but still an easy improvement to make. Finally, as Matthew suggests, add a godoc line about our behavior when a cue.mod/module.cue file is not present. Signed-off-by: Daniel Martí <[email protected]> Change-Id: If387adcc860c13bd80d04c4b5cde69385934cf2d Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1198065 Unity-Result: CUE porcuepine <[email protected]> Reviewed-by: Matthew Sackman <[email protected]> TryBot-Result: CUEcueckoo <[email protected]>
- Loading branch information