@@ -48,7 +48,8 @@ ResourceCache::~ResourceCache() {
4848
4949void ResourceCache::incrementRefcount (void * resource, ResourceType resourceType) {
5050 Mutex::Autolock _l (mLock );
51- ResourceReference* ref = mCache ->indexOfKey (resource) >= 0 ? mCache ->valueFor (resource) : NULL ;
51+ ssize_t index = mCache ->indexOfKey (resource);
52+ ResourceReference* ref = index >= 0 ? mCache ->valueAt (index) : NULL ;
5253 if (ref == NULL || mCache ->size () == 0 ) {
5354 ref = new ResourceReference (resourceType);
5455 mCache ->add (resource, ref);
@@ -78,7 +79,8 @@ void ResourceCache::incrementRefcount(SkiaColorFilter* filterResource) {
7879
7980void ResourceCache::decrementRefcount (void * resource) {
8081 Mutex::Autolock _l (mLock );
81- ResourceReference* ref = mCache ->indexOfKey (resource) >= 0 ? mCache ->valueFor (resource) : NULL ;
82+ ssize_t index = mCache ->indexOfKey (resource);
83+ ResourceReference* ref = index >= 0 ? mCache ->valueAt (index) : NULL ;
8284 if (ref == NULL ) {
8385 // Should not get here - shouldn't get a call to decrement if we're not yet tracking it
8486 return ;
@@ -111,12 +113,13 @@ void ResourceCache::decrementRefcount(SkiaColorFilter* filterResource) {
111113
112114void ResourceCache::recycle (SkBitmap* resource) {
113115 Mutex::Autolock _l (mLock );
114- if (mCache ->indexOfKey (resource) < 0 ) {
116+ ssize_t index = mCache ->indexOfKey (resource);
117+ if (index < 0 ) {
115118 // not tracking this resource; just recycle the pixel data
116119 resource->setPixels (NULL , NULL );
117120 return ;
118121 }
119- ResourceReference* ref = mCache ->indexOfKey (resource) >= 0 ? mCache -> valueFor (resource) : NULL ;
122+ ResourceReference* ref = mCache ->valueAt (index) ;
120123 if (ref == NULL ) {
121124 // Should not get here - shouldn't get a call to recycle if we're not yet tracking it
122125 return ;
@@ -129,7 +132,8 @@ void ResourceCache::recycle(SkBitmap* resource) {
129132
130133void ResourceCache::destructor (SkPath* resource) {
131134 Mutex::Autolock _l (mLock );
132- ResourceReference* ref = mCache ->indexOfKey (resource) >= 0 ? mCache ->valueFor (resource) : NULL ;
135+ ssize_t index = mCache ->indexOfKey (resource);
136+ ResourceReference* ref = index >= 0 ? mCache ->valueAt (index) : NULL ;
133137 if (ref == NULL ) {
134138 // If we're not tracking this resource, just delete it
135139 if (Caches::hasInstance ()) {
@@ -146,7 +150,8 @@ void ResourceCache::destructor(SkPath* resource) {
146150
147151void ResourceCache::destructor (SkBitmap* resource) {
148152 Mutex::Autolock _l (mLock );
149- ResourceReference* ref = mCache ->indexOfKey (resource) >= 0 ? mCache ->valueFor (resource) : NULL ;
153+ ssize_t index = mCache ->indexOfKey (resource);
154+ ResourceReference* ref = index >= 0 ? mCache ->valueAt (index) : NULL ;
150155 if (ref == NULL ) {
151156 // If we're not tracking this resource, just delete it
152157 if (Caches::hasInstance ()) {
@@ -163,7 +168,8 @@ void ResourceCache::destructor(SkBitmap* resource) {
163168
164169void ResourceCache::destructor (SkiaShader* resource) {
165170 Mutex::Autolock _l (mLock );
166- ResourceReference* ref = mCache ->indexOfKey (resource) >= 0 ? mCache ->valueFor (resource) : NULL ;
171+ ssize_t index = mCache ->indexOfKey (resource);
172+ ResourceReference* ref = index >= 0 ? mCache ->valueAt (index) : NULL ;
167173 if (ref == NULL ) {
168174 // If we're not tracking this resource, just delete it
169175 delete resource;
@@ -177,7 +183,8 @@ void ResourceCache::destructor(SkiaShader* resource) {
177183
178184void ResourceCache::destructor (SkiaColorFilter* resource) {
179185 Mutex::Autolock _l (mLock );
180- ResourceReference* ref = mCache ->indexOfKey (resource) >= 0 ? mCache ->valueFor (resource) : NULL ;
186+ ssize_t index = mCache ->indexOfKey (resource);
187+ ResourceReference* ref = index >= 0 ? mCache ->valueAt (index) : NULL ;
181188 if (ref == NULL ) {
182189 // If we're not tracking this resource, just delete it
183190 delete resource;
0 commit comments