summaryrefslogtreecommitdiffstats
path: root/gallerycommon/src/com/android/gallery3d/common
diff options
context:
space:
mode:
authorChih-Chung Chang <chihchung@google.com>2012-02-18 06:17:18 +0800
committerChih-Chung Chang <chihchung@google.com>2012-02-22 02:26:45 +0800
commitbe55f1e81c6021cf499c24331088fb01a8db9f91 (patch)
treee8634763af97adfa57428c76e381f4cfc92b1688 /gallerycommon/src/com/android/gallery3d/common
parentb3d01963463a11d27c286ffbf7f715f59bbecf88 (diff)
downloadandroid_packages_apps_Snap-be55f1e81c6021cf499c24331088fb01a8db9f91.tar.gz
android_packages_apps_Snap-be55f1e81c6021cf499c24331088fb01a8db9f91.tar.bz2
android_packages_apps_Snap-be55f1e81c6021cf499c24331088fb01a8db9f91.zip
Reduce memory allocation and make small improvements.
Change-Id: Iac3f302454119de6363cd5cfb158619e739b0536
Diffstat (limited to 'gallerycommon/src/com/android/gallery3d/common')
-rw-r--r--gallerycommon/src/com/android/gallery3d/common/Utils.java14
1 files changed, 8 insertions, 6 deletions
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.