servo/components/script
Simon Sapin d2be5239f5 Avoid returning / passing around a huge ParsedDeclaration type
This enum type used to contain the result of parsing
one CSS source declaration (`name: value;`) and expanding shorthands.
Enum types are as big as the biggest of their variant (plus discriminant),
which was quite big because some shorthands
expand to many longhand properties.
This type was returned through many functions and methods,
wrapped and rewrapped in `Result` with different error types.
This presumably caused significant `memmove` traffic.

Instead, we now allocate an `ArrayVec` on the stack
and pass `&mut` references to it for various functions to push into it.
This type is also very big, but we never move it.

We still use an intermediate data structure because we sometimes decide
after shorthand expansion that a declaration is invalid after all
and that we’re gonna drop it.
Only later do we push to a `PropertyDeclarationBlock`,
with an entire `ArrayVec` or nothing.

In future work we can try to avoid a large stack-allocated array,
and instead writing directly to the heap allocation
of the `Vec` inside `PropertyDeclarationBlock`.
However this is tricky:
we need to preserve this "all or nothing" aspect
of parsing one source declaration,
and at the same time we want to make it as little error-prone as possible
for the various call sites.
`PropertyDeclarationBlock` curently does property deduplication
incrementally: as each `PropertyDeclaration` is pushed,
we check if an existing declaration of the same property exists
and if so overwrite it.
To get rid of the stack allocated array we’d need to somehow
deduplicate separately after pushing multiple `PropertyDeclaration`.
2017-05-19 18:53:25 +02:00
..
docs Make #[dom_struct] a proc_macro attribute 2017-02-24 01:50:51 +01:00
dom Avoid returning / passing around a huge ParsedDeclaration type 2017-05-19 18:53:25 +02:00
task_source Properly implement TaskSource for NetworkingTaskSource 2016-11-11 14:50:42 -08:00
body.rs Rename Reflectable to DomObject. 2016-12-08 08:50:35 -10:00
build.rs Fix hardcoded path to link.exe 2017-02-03 13:33:37 +01:00
Cargo.toml Implement WebGL extensions. 2017-05-18 18:44:07 +02:00
clipboard_provider.rs
CMakeLists.txt Fix doc build by resurrecting generation of supported DOM APIs.h 2016-09-24 15:06:06 -04:00
devtools.rs Added some same-origin-domain checks. 2017-03-14 14:36:03 -05:00
document_loader.rs Remove mutability requirement from fetch_async_background. 2017-02-28 10:23:23 -05:00
fetch.rs Remove all internal mutability from Request 2017-04-03 12:39:07 +02:00
layout_image.rs Make image cache per-document rather than global 2017-03-27 19:54:13 +02:00
layout_wrapper.rs ol[type=…] and li[type=…] preshints need to be case-sensitive 2017-05-18 17:13:18 +02:00
lib.rs Implement WebGL extensions. 2017-05-18 18:44:07 +02:00
mem.rs Rename Reflectable to DomObject. 2016-12-08 08:50:35 -10:00
microtask.rs Mutation Observer API 2017-05-15 18:15:38 -04:00
network_listener.rs Separate the async bluetooth handling from networking code. 2016-12-21 14:52:39 +01:00
script_runtime.rs Implemented Houdini worklets. 2017-05-17 09:01:05 -05:00
script_thread.rs Implemented Houdini worklets. 2017-05-17 09:01:05 -05:00
serviceworker_manager.rs Removed util. 2016-12-14 18:04:37 -06:00
serviceworkerjob.rs Remove incorrect uses of asynchronous tasks from ServiceWorker job queue. 2017-02-01 12:54:33 -05:00
stylesheet_loader.rs Fix up script and layout. 2017-05-02 17:35:45 -07:00
test.rs Added compiletest to verify TrustedPromise does not implement Clone 2017-01-22 20:12:07 +00:00
textinput.rs Auto merge of #15822 - charlesvdv:unicode-panic, r=emilio 2017-04-16 15:08:59 -05:00
timers.rs Terminate timer scheduler thread during shutdown 2017-03-30 14:27:40 +02:00
unpremultiplytable.rs
webdriver_handlers.rs Renamed constellation::Frame to constellation::BrowsingContext. 2017-05-15 21:03:11 -05:00