Skip to content

Commit 7c21de8

Browse files
ono-maxko1
authored andcommitted
CDP: send "Debugger.scriptParsed" only when a new file path is found
This change improves the performance in Chrome Debugging We do not have to send "Debugger.scriptParsed" when the path is known
1 parent 61e378c commit 7c21de8

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

lib/debug/server_cdp.rb

+9-11
Original file line numberDiff line numberDiff line change
@@ -849,27 +849,25 @@ def process_protocol_result args
849849
unless s_id = @scr_id_map[path]
850850
s_id = (@scr_id_map.size + 1).to_s
851851
@scr_id_map[path] = s_id
852+
lineno = 0
853+
src = ''
852854
if path && File.exist?(path)
853855
src = File.read(path)
856+
@src_map[s_id] = src
857+
lineno = src.lines.count
854858
end
855-
@src_map[s_id] = src
856-
end
857-
if src = @src_map[s_id]
858-
lineno = src.lines.count
859-
else
860-
lineno = 0
861-
end
862-
frame[:location][:scriptId] = s_id
863-
frame[:functionLocation][:scriptId] = s_id
864-
@ui.fire_event 'Debugger.scriptParsed',
859+
@ui.fire_event 'Debugger.scriptParsed',
865860
scriptId: s_id,
866-
url: frame[:url],
861+
url: path,
867862
startLine: 0,
868863
startColumn: 0,
869864
endLine: lineno,
870865
endColumn: 0,
871866
executionContextId: 1,
872867
hash: src.hash.inspect
868+
end
869+
frame[:location][:scriptId] = s_id
870+
frame[:functionLocation][:scriptId] = s_id
873871

874872
frame[:scopeChain].each {|s|
875873
oid = s.dig(:object, :objectId)

0 commit comments

Comments
 (0)