Minor C++ tweak
Cleanup
Fix performance regression

Don't set the debug hook and callback for a script if profiler is
not enabled for it.

This fixes a performance regression in that was introduced in commit
bcd13beffbe8bef1db5be90e96038230eb3e2ab6.