Skip to content

Instantly share code, notes, and snippets.

@siefca
Created April 19, 2024 13:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save siefca/fa2745999281440867de1d1a89243f6d to your computer and use it in GitHub Desktop.
Save siefca/fa2745999281440867de1d1a89243f6d to your computer and use it in GitHub Desktop.
CCACHE-66
From c7beb5c57d51c33747c0d1331ef25787a24779be Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pawe=C5=82=20Wilk?= <siefca@gnu.org>
Date: Fri, 19 Apr 2024 14:52:00 +0200
Subject: [PATCH] CCACHE-66: Improved equality checks for keywords
---
src/main/clojure/clojure/core/cache.clj | 6 +++---
src/main/clojure/clojure/core/cache/wrapped.clj | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/main/clojure/clojure/core/cache.clj b/src/main/clojure/clojure/core/cache.clj
index 7800345..91c0e0e 100644
--- a/src/main/clojure/clojure/core/cache.clj
+++ b/src/main/clojure/clojure/core/cache.clj
@@ -265,17 +265,17 @@
[[] q]
q)]
[#(apply dissoc % ks) q']))
(defcache TTLCacheQ [cache ttl q gen ttl-ms]
CacheProtocol
(lookup [this item]
(let [ret (lookup this item ::nope)]
- (when-not (= ::nope ret) ret)))
+ (when-not (identical? ::nope ret) ret)))
(lookup [this item not-found]
(if (has? this item)
(get cache item)
not-found))
(has? [_ item]
(and (let [[_ t] (get ttl item [0 (- ttl-ms)])]
(< (- (System/currentTimeMillis)
t)
@@ -516,23 +516,23 @@
(SoftReference. ::nil rq)
(SoftReference. v rq)))
(defcache SoftCache [^java.util.Map cache ^java.util.Map rcache rq]
CacheProtocol
(lookup [_ item]
(when-let [^SoftReference r (get cache (or item ::nil))]
(let [v (.get r)]
- (if (= ::nil v)
+ (if (identical? ::nil v)
nil
v))))
(lookup [_ item not-found]
(if-let [^SoftReference r (get cache (or item ::nil))]
(if-let [v (.get r)]
- (if (= ::nil v)
+ (if (identical? ::nil v)
nil
v)
not-found)
not-found))
(has? [_ item]
(let [item (or item ::nil)
^SoftReference cell (get cache item)]
(boolean
diff --git a/src/main/clojure/clojure/core/cache/wrapped.clj b/src/main/clojure/clojure/core/cache/wrapped.clj
index 6e55b17..6239126 100644
--- a/src/main/clojure/clojure/core/cache/wrapped.clj
+++ b/src/main/clojure/clojure/core/cache/wrapped.clj
@@ -53,17 +53,17 @@
v (c/lookup (swap! cache-atom
c/through-cache
e
default-wrapper-fn
(fn [_] @d-new-value))
e
::expired)]
(when (< n 10)
- (if (= ::expired v)
+ (if (identical? ::expired v)
(recur (inc n)
(c/lookup (swap! cache-atom
c/through-cache
e
default-wrapper-fn
(fn [_] @d-new-value))
e
::expired))
--
2.40.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment