summaryrefslogtreecommitdiffstats
path: root/gallerycommon/src
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
commitd92874aa026e33a3011a30b6fcc17019f8b1c0be (patch)
tree1ac5fd79d98f623ada8a9b6b39a7012166b02ea3 /gallerycommon/src
parentc20bc57295c1b4b73ea65701a94efaf519955351 (diff)
downloadandroid_packages_apps_Snap-d92874aa026e33a3011a30b6fcc17019f8b1c0be.tar.gz
android_packages_apps_Snap-d92874aa026e33a3011a30b6fcc17019f8b1c0be.tar.bz2
android_packages_apps_Snap-d92874aa026e33a3011a30b6fcc17019f8b1c0be.zip
Reduce memory allocation and make small improvements.
Change-Id: Iac3f302454119de6363cd5cfb158619e739b0536
Diffstat (limited to 'gallerycommon/src')
-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.