|
566 | 566 |
|
567 | 567 | (defn- compare-symbols [a b]
|
568 | 568 | (cond
|
569 |
| - (= a b) 0 |
| 569 | + (identical? (.-str a) (.-str b)) 0 |
570 | 570 | (and (not (.-ns a)) (.-ns b)) -1
|
571 | 571 | (.-ns a) (if-not (.-ns b)
|
572 | 572 | 1
|
573 |
| - (let [nsc (compare (.-ns a) (.-ns b))] |
574 |
| - (if (zero? nsc) |
575 |
| - (compare (.-name a) (.-name b)) |
| 573 | + (let [nsc (garray/defaultCompare (.-ns a) (.-ns b))] |
| 574 | + (if (== 0 nsc) |
| 575 | + (garray/defaultCompare (.-name a) (.-name b)) |
576 | 576 | nsc)))
|
577 |
| - :default (compare (.-name a) (.-name b)))) |
| 577 | + :default (garray/defaultCompare (.-name a) (.-name b)))) |
578 | 578 |
|
579 | 579 | (deftype Symbol [ns name str ^:mutable _hash _meta]
|
580 | 580 | Object
|
@@ -2419,6 +2419,18 @@ reduces them without incurring seq initialization"
|
2419 | 2419 | (defn hash-keyword [k]
|
2420 | 2420 | (int (+ (hash-symbol k) 0x9e3779b9)))
|
2421 | 2421 |
|
| 2422 | +(defn- compare-keywords [a b] |
| 2423 | + (cond |
| 2424 | + (identical? (.-fqn a) (.-fqn b)) 0 |
| 2425 | + (and (not (.-ns a)) (.-ns b)) -1 |
| 2426 | + (.-ns a) (if-not (.-ns b) |
| 2427 | + 1 |
| 2428 | + (let [nsc (garray/defaultCompare (.-ns a) (.-ns b))] |
| 2429 | + (if (== 0 nsc) |
| 2430 | + (garray/defaultCompare (.-name a) (.-name b)) |
| 2431 | + nsc))) |
| 2432 | + :default (garray/defaultCompare (.-name a) (.-name b)))) |
| 2433 | + |
2422 | 2434 | (deftype Keyword [ns name fqn ^:mutable _hash]
|
2423 | 2435 | Object
|
2424 | 2436 | (toString [_] (str ":" fqn))
|
@@ -8307,8 +8319,7 @@ reduces them without incurring seq initialization"
|
8307 | 8319 | (-compare [x y] (compare-symbols x y))
|
8308 | 8320 |
|
8309 | 8321 | Keyword
|
8310 |
| - ; keyword happens to have the same fields as Symbol, so this just works |
8311 |
| - (-compare [x y] (compare-symbols x y)) |
| 8322 | + (-compare [x y] (compare-keywords x y)) |
8312 | 8323 |
|
8313 | 8324 | Subvec
|
8314 | 8325 | (-compare [x y] (compare-indexed x y))
|
|
0 commit comments