summaryrefslogtreecommitdiffstats
path: root/android_webview
diff options
context:
space:
mode:
authornewt@chromium.org <newt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-27 20:03:40 +0000
committernewt@chromium.org <newt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-27 20:03:40 +0000
commite5e3129f1cc5ce8a01e7941ad4a8254deccf6a28 (patch)
treeebeb5327ce86d30bcef0b9cf6b4928de28114cfc /android_webview
parent785d5143b5ae1c800ea1b3cb0f32b63c53b86ab2 (diff)
downloadchromium_src-e5e3129f1cc5ce8a01e7941ad4a8254deccf6a28.zip
chromium_src-e5e3129f1cc5ce8a01e7941ad4a8254deccf6a28.tar.gz
chromium_src-e5e3129f1cc5ce8a01e7941ad4a8254deccf6a28.tar.bz2
Use SparseArrays instead of HashMaps with Integer keys.
BUG=347356 NOTRY=true Review URL: https://codereview.chromium.org/182533003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@253912 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'android_webview')
-rw-r--r--android_webview/java/src/org/chromium/android_webview/AwResource.java11
1 files changed, 5 insertions, 6 deletions
diff --git a/android_webview/java/src/org/chromium/android_webview/AwResource.java b/android_webview/java/src/org/chromium/android_webview/AwResource.java
index a4fddcb..ee658e4 100644
--- a/android_webview/java/src/org/chromium/android_webview/AwResource.java
+++ b/android_webview/java/src/org/chromium/android_webview/AwResource.java
@@ -5,6 +5,7 @@
package org.chromium.android_webview;
import android.content.res.Resources;
+import android.util.SparseArray;
import org.chromium.base.CalledByNative;
import org.chromium.base.JNINamespace;
@@ -12,8 +13,6 @@ import org.chromium.base.JNINamespace;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.ref.SoftReference;
-import java.util.HashMap;
-import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Scanner;
@@ -41,14 +40,14 @@ public class AwResource {
private static Resources sResources;
// Loading some resources is expensive, so cache the results.
- private static Map<Integer, SoftReference<String> > sResourceCache;
+ private static SparseArray<SoftReference<String>> sResourceCache;
private static final int TYPE_STRING = 0;
private static final int TYPE_RAW = 1;
public static void setResources(Resources resources) {
sResources = resources;
- sResourceCache = new HashMap<Integer, SoftReference<String> >();
+ sResourceCache = new SparseArray<SoftReference<String>>();
}
public static void setErrorPageResources(int loaderror, int nodomain) {
@@ -80,8 +79,8 @@ public class AwResource {
assert sResources != null;
assert sResourceCache != null;
- String result = sResourceCache.get(resid) == null ?
- null : sResourceCache.get(resid).get();
+ SoftReference<String> stringRef = sResourceCache.get(resid);
+ String result = stringRef == null ? null : stringRef.get();
if (result == null) {
switch (type) {
case TYPE_STRING: