Commit 063428f
committed
Rewrite nrepl-log--pp-listlike as a single pass
The old implementation copy-sequence'd the cdr, seq-partition'd into
pairs, sorted alphabetically, seq-map'd for name lengths, seq-max'd,
seq-filter + seq-remove'd to split off special keys, seq-concatenate'd
twice, apply'd seq-concatenate to flatten back into a plist, then
cl-loop'd to emit -- roughly six list-sized allocations plus an
O(n log n) sort per logged message, half of it just to assemble a
plist that immediately got destructured again.
Replace with one pass: bucket special keys into a fixed-position
vector (so they emit in canonical id/op/session/time-stamp order
without sorting), collect the rest in insertion order, and track the
widest key inline for column alignment. No more sort, no more
copy-sequence, allocations down to a single small vector plus the
others list.
Behavior change: non-special keys now print in the order they appeared
in the dict instead of alphabetically. The order reflects how the
peer constructed the message, which is more useful for protocol
debugging than alphabetic by accident.1 parent 7999c4e commit 063428f
1 file changed
Lines changed: 27 additions & 20 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1396 | 1396 | | |
1397 | 1397 | | |
1398 | 1398 | | |
| 1399 | + | |
| 1400 | + | |
| 1401 | + | |
1399 | 1402 | | |
1400 | 1403 | | |
1401 | 1404 | | |
| |||
1407 | 1410 | | |
1408 | 1411 | | |
1409 | 1412 | | |
| 1413 | + | |
| 1414 | + | |
| 1415 | + | |
| 1416 | + | |
| 1417 | + | |
| 1418 | + | |
1410 | 1419 | | |
1411 | | - | |
1412 | | - | |
1413 | | - | |
1414 | | - | |
1415 | | - | |
1416 | | - | |
1417 | | - | |
1418 | | - | |
1419 | | - | |
1420 | | - | |
1421 | | - | |
| 1420 | + | |
| 1421 | + | |
| 1422 | + | |
| 1423 | + | |
| 1424 | + | |
| 1425 | + | |
| 1426 | + | |
| 1427 | + | |
| 1428 | + | |
1422 | 1429 | | |
1423 | | - | |
1424 | | - | |
1425 | | - | |
1426 | | - | |
1427 | | - | |
1428 | | - | |
1429 | | - | |
1430 | | - | |
1431 | | - | |
| 1430 | + | |
| 1431 | + | |
| 1432 | + | |
| 1433 | + | |
| 1434 | + | |
| 1435 | + | |
| 1436 | + | |
| 1437 | + | |
| 1438 | + | |
1432 | 1439 | | |
1433 | 1440 | | |
1434 | 1441 | | |
| |||
0 commit comments