Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

optimize getLine() #8

Merged
merged 1 commit into from

2 participants

@guileen

try/catch is expensive

@igo igo merged commit 6dc86de into igo:master
@igo
Owner

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 24, 2011
  1. @guileen

    optimize getLine()

    guileen authored
This page is out of date. Refresh to see the latest.
Showing with 4 additions and 7 deletions.
  1. +4 −7 lib/nlogger.js
View
11 lib/nlogger.js
@@ -54,13 +54,10 @@ function getDate() {
}
function getLine() {
- try {
- throw new Error();
- } catch(e) {
- // now magic will happen: get line number from callstack
- var line = e.stack.split('\n')[3].split(':')[1];
- return line;
- }
+ var e = new Error();
+ // now magic will happen: get line number from callstack
+ var line = e.stack.split('\n')[3].split(':')[1];
+ return line;
}
function getClass(module) {
Something went wrong with that request. Please try again.