-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Caching and caching tests improvements #1808
Conversation
It is already covered by some other tests, but not directly, resulting in an uncovered branch. Places already covering this function: 1. Deprecation test for `options.client` (under-the-hood) 2. All the test cases
I'll merge this in two days if no one reviews, to keep PRs from rotting. |
If we did, function handleFileCache (options) {
if (options.cache && exports.cache[options.filename]) {
return exports.cache[options.filename];
} else {
var result = exports.compile(fs.readFileSync(options.filename, 'utf8'), options);
if (options.cache) exports.cache[options.filename] = result;
return result;
}
} We could skip the extra (totally pointless) cache of the source strings. |
(2nd if's condition should read |
Thanks, updated |
IIRC I tried that but it didn't work for some obscure reason I do not recall right now. Will get back to you. |
Updated PR. Removed handleSrcCache() altogether. |
? exports.cache[key] || (exports.cache[key] = fs.readFileSync(path, 'utf8')) | ||
: fs.readFileSync(path, 'utf8'); | ||
return exports.render(str, options); | ||
return exports.render(null, options); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it would be better if this did:
return handleTemplateCache(options)(options);
It's not much duplicated code, and it keeps exports.render
from needing to accept null
for the string. We could then add a check in exports.render
that throws if str === null
to catch that odd corner case. I'd hate to end up having to support it forever.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True.
b2fc998
to
781901a
Compare
Caching and caching tests improvements
No description provided.