mirror of
https://github.com/servo/servo.git
synced 2025-08-01 11:40:30 +01:00
Auto merge of #13785 - gterzian:use_veqdequeu_in_servoparser, r=nox
switch to using DOMRefCell<VeqDeque<String>> for ServoParser::pending… <!-- Please describe your changes on the following line: --> The field ServoParser::pending_input should be a DOMRefCell<VeqDeque<String>>, this lets us use VecDeque::pop_front instead of Vec::remove in ServoParser::take_next_input_chunk. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #13690 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> …_input <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/13785) <!-- Reviewable:end -->
This commit is contained in:
commit
0b697c1080
2 changed files with 15 additions and 5 deletions
|
@ -78,7 +78,7 @@ use serde::{Deserialize, Serialize};
|
|||
use smallvec::SmallVec;
|
||||
use std::boxed::FnBox;
|
||||
use std::cell::{Cell, UnsafeCell};
|
||||
use std::collections::{BTreeMap, HashMap, HashSet};
|
||||
use std::collections::{BTreeMap, HashMap, HashSet, VecDeque};
|
||||
use std::hash::{BuildHasher, Hash};
|
||||
use std::ops::{Deref, DerefMut};
|
||||
use std::path::PathBuf;
|
||||
|
@ -208,6 +208,15 @@ impl<T: JSTraceable> JSTraceable for Vec<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T: JSTraceable> JSTraceable for VecDeque<T> {
|
||||
#[inline]
|
||||
fn trace(&self, trc: *mut JSTracer) {
|
||||
for e in &*self {
|
||||
e.trace(trc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: JSTraceable> JSTraceable for (T, T, T, T) {
|
||||
fn trace(&self, trc: *mut JSTracer) {
|
||||
self.0.trace(trc);
|
||||
|
|
|
@ -34,6 +34,7 @@ use profile_traits::time::{TimerMetadata, TimerMetadataFrameType};
|
|||
use profile_traits::time::{TimerMetadataReflowType, ProfilerCategory, profile};
|
||||
use script_thread::ScriptThread;
|
||||
use std::cell::Cell;
|
||||
use std::collections::VecDeque;
|
||||
use url::Url;
|
||||
use util::resource_files::read_resource_file;
|
||||
use xml5ever::tokenizer::XmlTokenizer;
|
||||
|
@ -51,7 +52,7 @@ pub struct ServoParser {
|
|||
/// does not correspond to a page load.
|
||||
pipeline: Option<PipelineId>,
|
||||
/// Input chunks received but not yet passed to the parser.
|
||||
pending_input: DOMRefCell<Vec<String>>,
|
||||
pending_input: DOMRefCell<VecDeque<String>>,
|
||||
/// The tokenizer of this parser.
|
||||
tokenizer: DOMRefCell<Tokenizer>,
|
||||
/// Whether to expect any further input from the associated network request.
|
||||
|
@ -78,7 +79,7 @@ impl ServoParser {
|
|||
reflector: Reflector::new(),
|
||||
document: JS::from_ref(document),
|
||||
pipeline: pipeline,
|
||||
pending_input: DOMRefCell::new(vec![]),
|
||||
pending_input: DOMRefCell::new(VecDeque::new()),
|
||||
tokenizer: DOMRefCell::new(tokenizer),
|
||||
last_chunk_received: Cell::new(last_chunk_state == LastChunkState::Received),
|
||||
suspended: Default::default(),
|
||||
|
@ -111,7 +112,7 @@ impl ServoParser {
|
|||
}
|
||||
|
||||
fn push_input_chunk(&self, chunk: String) {
|
||||
self.pending_input.borrow_mut().push(chunk);
|
||||
self.pending_input.borrow_mut().push_back(chunk);
|
||||
}
|
||||
|
||||
fn take_next_input_chunk(&self) -> Option<String> {
|
||||
|
@ -119,7 +120,7 @@ impl ServoParser {
|
|||
if pending_input.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(pending_input.remove(0))
|
||||
pending_input.pop_front()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue