Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Excessive ^$ regexp. #30

Closed
AlexeyKupershtokh opened this Issue Nov 14, 2012 · 1 comment

Comments

Projects
None yet
3 participants

the debug module by default creates the ^$ regexp which is unnecessary, harmful, and makes things run slower.
Test case:

var mod = require('..');
var debug = mod('tes');
debug('x1');
var debug2 = mod('');
debug2('x2');

(process.env.DEBUG || '')
  .split(/[\s,]+/)
  .forEach(function(name){
    name = name.replace('*', '.*?');
    console.log('^' + name + '$');
  });

Output:

wicked@wicked-desktop:~/debug$ node example/test2.js 
   x2 +0ms
^$

Consider there's no DEBUG env in the call.

Owner

tj commented Nov 14, 2012

ah right, stupid split, slowness doesn't really matter there though.. it's only called once per require('debug')()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment