Skip to content

Commit d04394f

Browse files
committed
optimize
1 parent 47c1dd0 commit d04394f

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

wrapper-java/src/main/java/com/whl/quickjs/wrapper/QuickJSContext.java

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import java.io.Closeable;
44
import java.io.File;
5-
import java.io.IOException;
65
import java.util.ArrayList;
76
import java.util.HashMap;
87
import java.util.Iterator;
@@ -135,24 +134,30 @@ public long getMemoryUsedSize() {
135134
}
136135

137136
public void dumpMemoryUsage(File target) {
138-
if (target == null || !target.exists()) {
139-
return;
137+
checkSameThread();
138+
checkDestroyed();
139+
String fileName = null;
140+
if (target != null && target.exists()) {
141+
fileName = target.getAbsolutePath();
140142
}
141143

142-
dumpMemoryUsage(runtime, target.getAbsolutePath());
144+
dumpMemoryUsage(runtime, fileName);
143145
}
144146

145147
// will use stdout to print.
146148
public void dumpMemoryUsage() {
147-
dumpMemoryUsage(runtime, null);
149+
dumpMemoryUsage(null);
148150
}
149151

150152
public void dumpObjects(File target) {
151-
if (target == null || !target.exists()) {
152-
return;
153+
checkSameThread();
154+
checkDestroyed();
155+
String fileName = null;
156+
if (target != null && target.exists()) {
157+
fileName = target.getAbsolutePath();
153158
}
154159

155-
dumpObjects(runtime, target.getAbsolutePath());
160+
dumpObjects(runtime, fileName);
156161
}
157162

158163
public JSObjectCreator getCreator() {
@@ -161,7 +166,7 @@ public JSObjectCreator getCreator() {
161166

162167
// will use stdout to print.
163168
public void dumpObjects() {
164-
dumpObjects(runtime, null);
169+
dumpObjects(null);
165170
}
166171

167172
private final long runtime;

0 commit comments

Comments
 (0)