From be55f1e81c6021cf499c24331088fb01a8db9f91 Mon Sep 17 00:00:00 2001 From: Chih-Chung Chang Date: Sat, 18 Feb 2012 06:17:18 +0800 Subject: Reduce memory allocation and make small improvements. Change-Id: Iac3f302454119de6363cd5cfb158619e739b0536 --- gallerycommon/src/com/android/gallery3d/common/Utils.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'gallerycommon/src/com/android/gallery3d/common') diff --git a/gallerycommon/src/com/android/gallery3d/common/Utils.java b/gallerycommon/src/com/android/gallery3d/common/Utils.java index ea289a628..6996015a3 100644 --- a/gallerycommon/src/com/android/gallery3d/common/Utils.java +++ b/gallerycommon/src/com/android/gallery3d/common/Utils.java @@ -54,12 +54,14 @@ public class Utils { } } - // Throws AssertionError if the input is false. - public static void assertTrue(boolean cond, String message, Object ... args) { - if (!cond) { - throw new AssertionError( - args.length == 0 ? message : String.format(message, args)); - } + // Throws AssertionError with the message. We had a method having the form + // assertTrue(boolean cond, String message, Object ... args); + // However a call to that method will cause memory allocation even if the + // condition is false (due to autoboxing generated by "Object ... args"), + // so we don't use that anymore. + public static void fail(String message, Object ... args) { + throw new AssertionError( + args.length == 0 ? message : String.format(message, args)); } // Throws NullPointerException if the input is null. -- cgit v1.2.3