Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

switch to using DOMRefCell<VeqDeque<String>> for ServoParser::pending… #13785

Merged
merged 1 commit into from Oct 16, 2016
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

switch to using DOMRefCell<VeqDeque<String>> for ServoParser::pending…

…_input
  • Loading branch information
gterzian committed Oct 16, 2016
commit f1d0c8b8dff6baa9a368433120e619a014015a3b
@@ -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,15 +112,15 @@ 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> {
let mut pending_input = self.pending_input.borrow_mut();
if pending_input.is_empty() {
None
} else {
Some(pending_input.remove(0))
pending_input.pop_front()
}
}

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.