caching enabled status per logger by containmentbreach · Pull Request #799 · debug-js/debug

@containmentbreach

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

@containmentbreach

@coveralls

Coverage Status

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

1 similar comment

@coveralls

Coverage Status

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

@Qix-

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

@containmentbreach

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.

Qix-

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.

@containmentbreach @Qix-

Co-authored-by: Qix <Qix-@users.noreply.github.com>

@Qix-

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 locked as spam and limited conversation to collaborators

Jan 8, 2021