diff options
| author | Chih-Chung Chang <chihchung@google.com> | 2012-02-18 06:17:18 +0800 |
|---|---|---|
| committer | Chih-Chung Chang <chihchung@google.com> | 2012-02-22 02:26:45 +0800 |
| commit | cfa105d3934c4dfa14f02b693bfa97c8d17d56a9 (patch) | |
| tree | 16c0726c9974d54cf7a383c191eb8c2c8ef08ccb /gallerycommon/src/com | |
| parent | 7d19f7f4281f232b9dceee4a5df390c03e2bd16b (diff) | |
| download | android_packages_apps_Gallery2-cfa105d3934c4dfa14f02b693bfa97c8d17d56a9.tar.gz android_packages_apps_Gallery2-cfa105d3934c4dfa14f02b693bfa97c8d17d56a9.tar.bz2 android_packages_apps_Gallery2-cfa105d3934c4dfa14f02b693bfa97c8d17d56a9.zip | |
Reduce memory allocation and make small improvements.
Change-Id: Iac3f302454119de6363cd5cfb158619e739b0536
Diffstat (limited to 'gallerycommon/src/com')
| -rw-r--r-- | gallerycommon/src/com/android/gallery3d/common/Utils.java | 14 |
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. |
