(key, buildIndex)
| 428 | // transient inserts, where the node is reused so the O(n) build amortizes). |
| 429 | // Persistent inserts already pay an O(n) copy, so a throwaway index is skipped. |
| 430 | _positionOf(key, buildIndex) { |
| 431 | const entries = this.entries; |
| 432 | let index = this._index; |
| 433 | if ( |
| 434 | index === undefined && |
| 435 | buildIndex && |
| 436 | entries.length >= MIN_HASH_COLLISION_INDEX_SIZE |
| 437 | ) { |
| 438 | index = this._buildIndex(); |
| 439 | } |
| 440 | if (index !== undefined) { |
| 441 | const positions = index[hashCollisionKey(key)]; |
| 442 | if (positions !== undefined) { |
| 443 | for (let jj = 0; jj < positions.length; jj++) { |
| 444 | const ii = positions[jj]; |
| 445 | if (is(key, entries[ii][0])) { |
| 446 | return ii; |
| 447 | } |
| 448 | } |
| 449 | } |
| 450 | return -1; |
| 451 | } |
| 452 | for (let ii = 0, len = entries.length; ii < len; ii++) { |
| 453 | if (is(key, entries[ii][0])) { |
| 454 | return ii; |
| 455 | } |
| 456 | } |
| 457 | return -1; |
| 458 | } |
| 459 | |
| 460 | // Builds and memoizes the secondary index. A plain object, not `Map` — which |
| 461 | // in this module resolves to the *Immutable* Map, not the native one. |
no test coverage detected