Compare keywords can be very fast.
在 2012-7-18 PM4:51,"jaime" <[email protected]>写道:
> Hello,
>
> When I read the source code keyword, say, Keyword.java (V1.3), I found
> that when we "intern" a keyword, (if I understand it correctly) it uses
> a cache for keywords:
> =============================================
> public static Keyword intern(Symbol sym) {
> if (sym.meta() != null)
> sym = (Symbol) sym.withMeta(null);
> *Util.clearCache(rq, table);*
> Keyword k = new Keyword(sym);
> Reference<Keyword> existingRef = table.putIfAbsent(sym,
> new WeakReference<Keyword>(k, rq));
> if (existingRef == null)
> return k;
> Keyword existingk = existingRef.get();
> if (existingk != null)
> return existingk;
> // entry died in the interim, do over
> table.remove(sym, existingRef);
> return intern(sym);
> }
> ==============================================
>
> well, I just don't understand why we need caching for keywords. Anyone
> could give me a hint?
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to [email protected]
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en