Refactor Record and List to use TupleData
The `Value::List` and `Value::Record` variants have been consolidated into a single `Value::Tuple` variant. This new variant uses a `TupleData` struct to store values and an optional `Rc<Vec<Keyword>>` for keys, allowing it to represent both ordered lists/tuples and key-value records. This change simplifies the internal representation and improves performance by allowing schema sharing for records. It also includes updates to the compiler, runtime, and tests to reflect the new structure.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
;; Record to Tuple Mapping Test
|
||||
;; Output: 30
|
||||
;; Benchmark: 700ns
|
||||
(do
|
||||
(def rec {:x 10 :y 20})
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
;; Benchmark: Record Destructuring Performance
|
||||
;; This test calls a function that destructures a record 100.000 times.
|
||||
;; Current implementation is now zero-allocation for destructuring.
|
||||
;; Output: {:a 1, :b 2}
|
||||
;; Benchmark: 5.3ms
|
||||
(do
|
||||
(def process (fn [[x y]]
|
||||
(+ x y)))
|
||||
|
||||
(def rec {:a 1 :b 2})
|
||||
|
||||
(def loop (fn [n acc]
|
||||
(if (= n 0)
|
||||
acc
|
||||
(loop (- n 1) (process rec)))))
|
||||
|
||||
(loop 10000 0)
|
||||
rec
|
||||
)
|
||||
Reference in New Issue
Block a user