Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 33589258 authored by Pablo Gamito's avatar Pablo Gamito
Browse files

Handle null args list

To avoid an allocation when there are no args, the ProtoLog code processor passes null instead of the args object array.

Flag: NONE handling null case
Change-Id: I0eeaa79c4e4e4c4796f2a2e0d31f7848fd58ffc6
parent 5e8a165e
Loading
Loading
Loading
Loading
+9 −5
Original line number Diff line number Diff line
@@ -170,7 +170,7 @@ public class PerfettoProtoLogImpl implements IProtoLog {
    @VisibleForTesting
    @Override
    public void log(LogLevel level, IProtoLogGroup group, long messageHash, int paramsMask,
            Object[] args) {
            @Nullable Object[] args) {
        Trace.traceBegin(Trace.TRACE_TAG_WINDOW_MANAGER, "log");

        try {
@@ -297,7 +297,8 @@ public class PerfettoProtoLogImpl implements IProtoLog {
        os.end(outMessagesToken);
    }

    private void logToLogcat(String tag, LogLevel level, long messageHash, Object[] args) {
    private void logToLogcat(String tag, LogLevel level, long messageHash,
            @Nullable Object[] args) {
        Trace.traceBegin(Trace.TRACE_TAG_WINDOW_MANAGER, "logToLogcat");
        try {
            doLogToLogcat(tag, level, messageHash, args);
@@ -306,7 +307,8 @@ public class PerfettoProtoLogImpl implements IProtoLog {
        }
    }

    private void doLogToLogcat(String tag, LogLevel level, long messageHash, Object[] args) {
    private void doLogToLogcat(String tag, LogLevel level, long messageHash,
            @Nullable Object[] args) {
        String message = null;
        String messageString = mViewerConfigReader.getViewerString(messageHash);
        if (messageString != null) {
@@ -322,9 +324,11 @@ public class PerfettoProtoLogImpl implements IProtoLog {
        }
        if (message == null) {
            StringBuilder builder = new StringBuilder("UNKNOWN MESSAGE (" + messageHash + ")");
            if (args != null) {
                for (Object o : args) {
                    builder.append(" ").append(o);
                }
            }
            message = builder.toString();
        }
        passToLogcat(tag, level, message);