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

Code optimization in _scriptSource: String#substr instead of String#spli... #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions js/VisualEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ VisualEvent.prototype = {
{
var origin = "";
var srcFiles = [];
var i, iLen, a;
var i, iLen, script, pos;

// Webkit reformats the prototype for the function, so the whitespace might not match our
// intended target. Remove the prototype - it means we are more likely to get a clash, but
Expand All @@ -476,11 +476,12 @@ VisualEvent.prototype = {
}

for ( i=0, iLen=this.s.scripts.length ; i<iLen ; i++ ) {
if ( this.s.scripts[i].code.indexOf( func ) !== -1 ) {
a = this.s.scripts[i].code.split( func );
script = this.s.scripts[i];
pos = script.code.indexOf( func );
if ( pos !== -1 ) {
srcFiles.push( {
"src": this.s.scripts[i].src,
"line": a[0].split('\n').length
"src": script.src,
"line": script.code.substr(0, pos).split('\n').length
} );
}
}
Expand Down