From 43d963285945e0b5d5aafd7a96f880dc0b76c34b Mon Sep 17 00:00:00 2001 From: Jack Firth Date: Wed, 30 Mar 2022 02:09:32 -0700 Subject: [PATCH] Use `hash-update!` where possible --- parser-tools/private-lex/deriv.rkt | 6 +----- parser-tools/private-yacc/lr0.rkt | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/parser-tools/private-lex/deriv.rkt b/parser-tools/private-lex/deriv.rkt index 77b7488..7f597e3 100644 --- a/parser-tools/private-lex/deriv.rkt +++ b/parser-tools/private-lex/deriv.rkt @@ -263,11 +263,7 @@ (set! new-state? #t) (state new-re (get-state-number))))] [new-all-states (if new-state? (cons new-state all-states) all-states)]) - (hash-set! transitions - s - (cons (cons c new-state) - (hash-ref transitions s - '()))) + (hash-update! transitions s (λ (v) (cons (cons c new-state) v)) '()) (cond [new-state? (loop old-states (cons new-state new-states) new-all-states (cdr cs))] diff --git a/parser-tools/private-yacc/lr0.rkt b/parser-tools/private-yacc/lr0.rkt index 193cd24..ce504d6 100644 --- a/parser-tools/private-yacc/lr0.rkt +++ b/parser-tools/private-yacc/lr0.rkt @@ -59,7 +59,7 @@ (define (reverse-assoc assoc) (define reverse-hash (make-hash)) (define (hash-table-add! ht k v) - (hash-set! ht k (cons v (hash-ref ht k '())))) + (hash-update! ht k (λ (v) (cons v v)) '())) (for ([trans-key/kernel (in-list assoc)]) (define tk (car trans-key/kernel)) (hash-table-add! reverse-hash