Skip to content

Commit a9a3b8e

Browse files
committed
Avoid allocation of lambdas for logging
1 parent dde1056 commit a9a3b8e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyContextFunctions.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
import static com.oracle.graal.python.builtins.objects.cext.hpy.GraalHPyNativeSymbol.GRAAL_HPY_WRITE_PTR;
6161

6262
import java.nio.charset.StandardCharsets;
63+
import java.util.logging.Level;
6364

6465
import com.oracle.graal.python.PythonLanguage;
6566
import com.oracle.graal.python.builtins.PythonBuiltinClassType;
@@ -1456,7 +1457,9 @@ Object execute(Object[] arguments,
14561457
// write data pointer to out var
14571458
callWriteDataNode.call(context, GRAAL_HPY_WRITE_PTR, dataOutVar, 0L, dataPtr);
14581459

1459-
LOGGER.fine(() -> String.format("Allocated HPy object with native space of size %d at %s", basicsize, dataPtr));
1460+
if (LOGGER.isLoggable(Level.FINEST)) {
1461+
LOGGER.finest(() -> String.format("Allocated HPy object with native space of size %d at %s", basicsize, dataPtr));
1462+
}
14601463
// TODO(fa): add memory tracing
14611464
}
14621465
return asHandleNode.execute(pythonObject);
@@ -1515,7 +1518,9 @@ Object execute(Object[] arguments,
15151518
Object dataPtr = callMallocNode.call(context, GraalHPyNativeSymbol.GRAAL_HPY_CALLOC, basicsize, 1L);
15161519
writeNativeSpaceNode.execute(pythonObject, OBJECT_HPY_NATIVE_SPACE, dataPtr);
15171520

1518-
LOGGER.fine(() -> String.format("Allocated HPy object with native space of size %d at %s", basicsize, dataPtr));
1521+
if (LOGGER.isLoggable(Level.FINEST)) {
1522+
LOGGER.finest(() -> String.format("Allocated HPy object with native space of size %d at %s", basicsize, dataPtr));
1523+
}
15191524
// TODO(fa): add memory tracing
15201525
}
15211526
return asHandleNode.execute(pythonObject);

0 commit comments

Comments
 (0)