performance improvement:

public void func() {
   synchronized(this) {
       ...
   }
}

is less efficient than

public synchronized void func() {
   ...
}
This commit is contained in:
Shu Lei
2008-02-21 01:00:43 +00:00
parent 1672e73c40
commit c170cd3fa0

View File

@@ -483,46 +483,39 @@ public class DebugLuaState extends LuaState implements DebugRequestListener {
/** /**
* suspend the execution * suspend the execution
*/ */
public void suspend() { public synchronized void suspend() {
synchronized (this) {
suspended = true; suspended = true;
stepping = STEP_NONE; stepping = STEP_NONE;
lastline = -1; lastline = -1;
this.notify(); this.notify();
} }
}
/** /**
* If the VM is suspended on start, this method resumes the execution. * If the VM is suspended on start, this method resumes the execution.
*/ */
protected void cancelSuspendOnStart() { protected synchronized void cancelSuspendOnStart() {
synchronized (this) {
if (bSuspendOnStart) { if (bSuspendOnStart) {
bSuspendOnStart = false; bSuspendOnStart = false;
this.notify(); this.notify();
} }
} }
}
/** /**
* resume the execution * resume the execution
*/ */
public void resume() { public synchronized void resume() {
synchronized (this) {
this.suspended = false; this.suspended = false;
this.stepping = STEP_NONE; this.stepping = STEP_NONE;
this.shouldPauseForStepping = false; this.shouldPauseForStepping = false;
this.steppingFrame = -1; this.steppingFrame = -1;
this.notify(); this.notify();
} }
}
/** /**
* Stops the debugging communication with the debug client and terminate the * Stops the debugging communication with the debug client and terminate the
* VM execution. * VM execution.
*/ */
public void stop() { public synchronized void stop() {
synchronized (this) {
if (exiting) return; if (exiting) return;
if (this.debugSupport != null) { if (this.debugSupport != null) {
@@ -537,7 +530,6 @@ public class DebugLuaState extends LuaState implements DebugRequestListener {
debugSupport = null; debugSupport = null;
} }
} }
}
public void disconnect() { public void disconnect() {
if (this.debugSupport == null) { if (this.debugSupport == null) {
@@ -561,24 +553,20 @@ public class DebugLuaState extends LuaState implements DebugRequestListener {
debugSupport.disconnect(); debugSupport.disconnect();
} }
public void reset() { public synchronized void reset() {
synchronized (this) {
this.breakpoints.clear(); this.breakpoints.clear();
if (this.suspended) { if (this.suspended) {
resume(); resume();
} }
} }
}
/** /**
* terminate the execution * terminate the execution
*/ */
public void exit() { public synchronized void exit() {
synchronized (this) {
exiting = true; exiting = true;
this.notify(); this.notify();
} }
}
/** /**
* set breakpoint at line N * set breakpoint at line N
@@ -822,35 +810,29 @@ public class DebugLuaState extends LuaState implements DebugRequestListener {
/** /**
* step over to next line * step over to next line
*/ */
public void stepOver() { public synchronized void stepOver() {
synchronized (this) {
suspended = false; suspended = false;
stepping = STEP_OVER; stepping = STEP_OVER;
steppingFrame = cc; steppingFrame = cc;
this.notify(); this.notify();
} }
}
/** /**
* step to the next statement * step to the next statement
*/ */
public void stepInto() { public synchronized void stepInto() {
synchronized (this) {
suspended = false; suspended = false;
stepping = STEP_INTO; stepping = STEP_INTO;
this.notify(); this.notify();
} }
}
/** /**
* return from the current method call * return from the current method call
*/ */
public void stepReturn() { public synchronized void stepReturn() {
synchronized (this) {
suspended = false; suspended = false;
stepping = STEP_RETURN; stepping = STEP_RETURN;
steppingFrame = cc; steppingFrame = cc;
this.notify(); this.notify();
} }
} }
}