mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-16 12:50:38 -07:00
perf: improve getTemplate() when cache is enabled
Checking for file existence is unnecessary when cache contains entry.
This commit is contained in:
committed by
Jun Yang
parent
bbebb5515c
commit
1ffba2bc76
+2
-1
@@ -51,9 +51,10 @@ export default class Liquid {
|
||||
const paths = roots.map(root => fs.resolve(root, file, this.options.extname))
|
||||
|
||||
for (const filepath of paths) {
|
||||
if (this.options.cache && this.cache[filepath]) return this.cache[filepath]
|
||||
|
||||
if (!(await fs.exists(filepath))) continue
|
||||
|
||||
if (this.options.cache && this.cache[filepath]) return this.cache[filepath]
|
||||
const value = this.parse(await fs.readFile(filepath), filepath)
|
||||
if (this.options.cache) this.cache[filepath] = value
|
||||
return value
|
||||
|
||||
Reference in New Issue
Block a user