Skip to content
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 enabled status per logger #799

Merged
merged 2 commits into from
Dec 9, 2020
Merged

Conversation

containmentbreach
Copy link
Contributor

Can we have this to avoid rechecking rules on each call?

@coveralls
Copy link

Coverage Status

Coverage increased (+0.3%) to 89.286% when pulling f0f645e on omg:master into 0d3d66b on visionmedia:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage increased (+0.3%) to 89.286% when pulling f0f645e on omg:master into 0d3d66b on visionmedia:master.

@Qix-
Copy link
Member

Qix- commented Dec 9, 2020

Please explain what this does. What problem are you facing?

@Qix- Qix- added the awaiting-response This issue or pull request is awaiting a user's response label Dec 9, 2020
@containmentbreach
Copy link
Contributor Author

Current implementation checks whether the namespace is enabled against the lists of regexes each time the debug instance is called. This change addresses this by caching the enabled flag in the debug instance to avoid reevaluating it each time. Since the library supports dynamically changing namespace configuration, the change also addresses this by caching reference to namespace config in the instance and comparing it against the current config (lazily). When the references are different the new config reference is replaces the previously cached one and the enabled flag reevaluated so nothing breaks but redundant regex checks are cut off.

Copy link
Member

@Qix- Qix- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, thanks!

Just a few small nitpicks and I'll merge.

src/common.js Outdated Show resolved Hide resolved
src/common.js Outdated Show resolved Hide resolved
src/common.js Outdated Show resolved Hide resolved
Co-authored-by: Qix <Qix-@users.noreply.github.com>
@Qix- Qix- merged commit 1e9d38c into debug-js:master Dec 9, 2020
@Qix-
Copy link
Member

Qix- commented Dec 9, 2020

Released as 4.3.2 on the beta tag. Thanks again :)

@Qix- Qix- added change-patch This proposes or provides a change that requires a patch release and removed awaiting-response This issue or pull request is awaiting a user's response labels Dec 9, 2020
@debug-js debug-js deleted a comment from diverdowngit Jan 8, 2021
@debug-js debug-js deleted a comment from diverdowngit Jan 8, 2021
@debug-js debug-js locked as spam and limited conversation to collaborators Jan 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
change-patch This proposes or provides a change that requires a patch release
Development

Successfully merging this pull request may close these issues.

3 participants