groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sun...@apache.org
Subject groovy git commit: Refine EvictableMemoizeCache
Date Sat, 09 Dec 2017 12:35:26 GMT
Repository: groovy
Updated Branches:
  refs/heads/master 2c0a3bf9c -> 1aa79fd56


Refine EvictableMemoizeCache


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/1aa79fd5
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/1aa79fd5
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/1aa79fd5

Branch: refs/heads/master
Commit: 1aa79fd5671f732b2b41bdb861b089d10e25f07f
Parents: 2c0a3bf
Author: sunlan <sunlan@apache.org>
Authored: Sat Dec 9 20:35:16 2017 +0800
Committer: sunlan <sunlan@apache.org>
Committed: Sat Dec 9 20:35:16 2017 +0800

----------------------------------------------------------------------
 .../groovy/runtime/memoize/EvictableMemoizeCache.java     |  4 ++--
 .../org/codehaus/groovy/runtime/memoize/SimpleCache.java  | 10 ++--------
 2 files changed, 4 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/1aa79fd5/src/main/org/codehaus/groovy/runtime/memoize/EvictableMemoizeCache.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/runtime/memoize/EvictableMemoizeCache.java b/src/main/org/codehaus/groovy/runtime/memoize/EvictableMemoizeCache.java
index 83b3498..a5dd318 100644
--- a/src/main/org/codehaus/groovy/runtime/memoize/EvictableMemoizeCache.java
+++ b/src/main/org/codehaus/groovy/runtime/memoize/EvictableMemoizeCache.java
@@ -29,9 +29,9 @@ public interface EvictableMemoizeCache<K, V> extends MemoizeCache<K,
V> {
     /**
      * Remove the cached value by the key
      * @param key
-     * @return returns false if there was no matching key
+     * @return returns the removed value
      */
-    boolean remove(K key);
+    V remove(K key);
 
     /**
      * Clear the cache

http://git-wip-us.apache.org/repos/asf/groovy/blob/1aa79fd5/src/main/org/codehaus/groovy/runtime/memoize/SimpleCache.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/runtime/memoize/SimpleCache.java b/src/main/org/codehaus/groovy/runtime/memoize/SimpleCache.java
index 50affef..4eb0453 100644
--- a/src/main/org/codehaus/groovy/runtime/memoize/SimpleCache.java
+++ b/src/main/org/codehaus/groovy/runtime/memoize/SimpleCache.java
@@ -94,25 +94,19 @@ public class SimpleCache<K, V> implements EvictableMemoizeCache<K,
V> {
         return value;
     }
 
-
-
     @Override
     public Collection<V> values() {
         return map.values();
     }
 
     @Override
-    public boolean remove(K key) {
-        V removedValue;
-
+    public V remove(K key) {
         writeLock.lock();
         try {
-            removedValue = map.remove(key);
+            return map.remove(key);
         } finally {
             writeLock.unlock();
         }
-
-        return null != removedValue;
     }
 
     @Override


Mime
View raw message