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

Separate interning text run #3369

Merged
merged 10 commits into from Dec 6, 2018
Next

Give intern::Interner an impl of Default.

  • Loading branch information
djg committed Dec 5, 2018
commit 87fe67ee9dedb503cfc292bfcd1799a93e0bffde
@@ -204,9 +204,12 @@ pub struct Interner<S : Eq + Hash + Clone + Debug, D, M> {
local_data: Vec<Item<D>>,
}

impl<S, D, M> Interner<S, D, M> where S: Eq + Hash + Clone + Debug, M: Copy + Debug {
/// Construct a new interner
pub fn new() -> Self {
impl<S, D, M> ::std::default::Default for Interner<S, D, M>
where
S: Eq + Hash + Clone + Debug,
M: Copy + Debug
{
fn default() -> Self {
Interner {
map: FastHashMap::default(),
free_list: Vec::new(),
@@ -217,7 +220,9 @@ impl<S, D, M> Interner<S, D, M> where S: Eq + Hash + Clone + Debug, M: Copy + De
local_data: Vec::new(),
}
}
}

impl<S, D, M> Interner<S, D, M> where S: Eq + Hash + Clone + Debug, M: Copy + Debug {
/// Intern a data structure, and return a handle to
/// that data. The handle can then be stored in the
/// frame builder, and safely accessed via the data
@@ -159,20 +159,12 @@ pub enum SceneSwapResult {
// display lists is (a) fast (b) done during scene building.
#[cfg_attr(feature = "capture", derive(Serialize))]
#[cfg_attr(feature = "replay", derive(Deserialize))]
#[derive(Default)]
pub struct DocumentResources {
pub clip_interner: ClipDataInterner,
pub prim_interner: PrimitiveDataInterner,
}

impl DocumentResources {
fn new() -> Self {
DocumentResources {
clip_interner: ClipDataInterner::new(),
prim_interner: PrimitiveDataInterner::new(),
}
}
}

// A document in the scene builder contains the current scene,
// as well as a persistent clip interner. This allows clips
// to be de-duplicated, and persisted in the GPU cache between
@@ -187,7 +179,7 @@ impl Document {
fn new(scene: Scene) -> Self {
Document {
scene,
resources: DocumentResources::new(),
resources: DocumentResources::default(),
prim_store_stats: PrimitiveStoreStats::empty(),
}
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.