Skip to content
This repository was archived by the owner on Apr 15, 2025. It is now read-only.

Commit 3a59a9b

Browse files
author
Robin Ricard
committed
Add performance expectations
1 parent 49340e9 commit 3a59a9b

File tree

1 file changed

+32
-4
lines changed

1 file changed

+32
-4
lines changed

README.md

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -253,13 +253,28 @@ Accessing a member expression of a tuple or record via `.` or `[]` follows the s
253253

254254
An instance of `Record` has the same keys and values as the `record` value it was created from. These keys are all `writable: false, enumerable: true, configurable: false`.
255255

256-
An instance of `Tuple` has keys that are `${index}` for each index in the original `tuple`. The value for each of these keys is the corresponding value in the original `tuple`. These keys are all `writable: false, enumerable: true, configurable: false`. In addition, there is a non-enumerable `length` key. This behavior matches that of the `String` wrapper object. That is, `Object.getOwnPropertyDescriptors(Object(#["a", "b"]))` and `Object.getOwnPropertyDescriptors(new String("ab"))` each return an object that looks like this:
256+
An instance of `Tuple` has keys that are `${index}` for each index in the original `tuple`. The value for each of these keys is the corresponding value in the original `tuple`. These keys are all `writable: false, enumerable: true, configurable: false`. In addition, there is a non-enumerable `length` key. This behavior matches that of the `String` wrapper object. That is, `Object.getOwnPropertyDescriptors(Object(#["a", "b"]))` and `Object.getOwnPropertyDescriptors(new String("ab"))` each return an object that looks like this:
257257

258258
```json
259259
{
260-
"0": { "value": "a", "writable": false, "enumerable": true, "configurable": false },
261-
"1": { "value": "b", "writable": false, "enumerable": true, "configurable": false },
262-
"length": { "value": 2, "writable": false, "enumerable": false, "configurable": false }
260+
"0": {
261+
"value": "a",
262+
"writable": false,
263+
"enumerable": true,
264+
"configurable": false
265+
},
266+
"1": {
267+
"value": "b",
268+
"writable": false,
269+
"enumerable": true,
270+
"configurable": false
271+
},
272+
"length": {
273+
"value": 2,
274+
"writable": false,
275+
"enumerable": false,
276+
"configurable": false
277+
}
263278
}
264279
```
265280

@@ -371,6 +386,19 @@ weakMap.set(record, true);
371386

372387
# FAQ
373388

389+
## What are the performance expectations of those Data Structures?
390+
391+
This proposal in itself does not put any performance guarantees and does not require specific optimizations on the implementers. It is however built in a way that some performance optimizations can be done in most cases if implementers choose to do so.
392+
393+
The way the proposal is built can enable a few things (among other):
394+
395+
- Structural sharing can be used to represent those data structures internally. Structural sharing enables faster copy and comparison.
396+
- This structural sharing can be partially derived from the existing shape system implemented in most engines
397+
- Those structures can be built in a thread-safe way so they can be used across workers
398+
- The web browser's structural cloning algorithm used to serialize data to a worker can be changed to only pass the thread safe structure across the boundary
399+
400+
Not all of those optimizations have to be done but the proposal and the way it's built should enable engines to eventually implement them more easily.
401+
374402
## Why #{}/#[] syntax? What about an existing or new keyword?
375403

376404
Using a keyword as a prefix to the standard object/array literal syntax presents issues around

0 commit comments

Comments
 (0)