From 3d8b7726271170beb4dced8e3f1d0b67f422638e Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Wed, 9 Mar 2016 16:08:02 +0100 Subject: [PATCH] WEB-19117 Debugger is extremely slow to start w/ Node.js 5.0.0 --- .../debugger-ui/src/DebugProcessImpl.kt | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/platform/script-debugger/debugger-ui/src/DebugProcessImpl.kt b/platform/script-debugger/debugger-ui/src/DebugProcessImpl.kt index 5a5ed158d4cb..5ef66a6360e8 100644 --- a/platform/script-debugger/debugger-ui/src/DebugProcessImpl.kt +++ b/platform/script-debugger/debugger-ui/src/DebugProcessImpl.kt @@ -256,15 +256,8 @@ abstract class DebugProcessImpl>(session: XDebugSession, protected fun addChildVm(vm: Vm) { beforeInitBreakpoints(vm) - val breakpointManager = XDebuggerManager.getInstance(session.project).breakpointManager - @Suppress("UNCHECKED_CAST") - for (breakpointHandler in breakpointHandlers) { - if (breakpointHandler is LineBreakpointHandler) { - val breakpoints = runReadAction { breakpointManager.getBreakpoints(breakpointHandler.breakpointTypeClass) } - for (breakpoint in breakpoints) { - breakpointHandler.manager.setBreakpoint(vm, breakpoint) - } - } + processBreakpoints { handler, breakpoint -> + handler.manager.setBreakpoint(vm, breakpoint) } } @@ -276,6 +269,18 @@ abstract class DebugProcessImpl>(session: XDebugSession, } } } + + protected inline fun processBreakpoints(processor: (handler: LineBreakpointHandler, breakpoint: XLineBreakpoint<*>) -> Unit) { + val breakpointManager = XDebuggerManager.getInstance(session.project).breakpointManager + for (breakpointHandler in breakpointHandlers) { + if (breakpointHandler is LineBreakpointHandler) { + val breakpoints = runReadAction { breakpointManager.getBreakpoints(breakpointHandler.breakpointTypeClass) } + for (breakpoint in breakpoints) { + processor(breakpointHandler, breakpoint) + } + } + } + } } @Suppress("UNCHECKED_CAST")