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

Commit 5115de84 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Do not hold synchronization locks if tracing is not enabled" into ub-launcher3-master

parents 42259240 89cbeb14
Loading
Loading
Loading
Loading
+32 −26
Original line number Diff line number Diff line
@@ -39,8 +39,9 @@ public class TraceHelper {
    private static final boolean SYSTEM_TRACE = false;
    private static final ArrayMap<String, MutableLong> sUpTimes = ENABLED ? new ArrayMap<>() : null;

    public static synchronized void beginSection(String sectionName) {
    public static void beginSection(String sectionName) {
        if (ENABLED) {
            synchronized (sUpTimes) {
                MutableLong time = sUpTimes.get(sectionName);
                if (time == null) {
                    time = new MutableLong(isLoggable(sectionName, VERBOSE) ? 0 : -1);
@@ -54,9 +55,11 @@ public class TraceHelper {
                }
            }
        }
    }

    public static synchronized void partitionSection(String sectionName, String partition) {
    public static void partitionSection(String sectionName, String partition) {
        if (ENABLED) {
            synchronized (sUpTimes) {
                MutableLong time = sUpTimes.get(sectionName);
                if (time != null && time.value >= 0) {

@@ -71,6 +74,7 @@ public class TraceHelper {
                }
            }
        }
    }

    public static void endSection(String sectionName) {
        if (ENABLED) {
@@ -78,8 +82,9 @@ public class TraceHelper {
        }
    }

    public static synchronized void endSection(String sectionName, String msg) {
    public static void endSection(String sectionName, String msg) {
        if (ENABLED) {
            synchronized (sUpTimes) {
                MutableLong time = sUpTimes.get(sectionName);
                if (time != null && time.value >= 0) {
                    if (SYSTEM_TRACE) {
@@ -90,3 +95,4 @@ public class TraceHelper {
            }
        }
    }
}