From fe8a413fc0f5d7d021ec42ac1a4149db662ca92c Mon Sep 17 00:00:00 2001 From: Alexis Beingessner Date: Thu, 18 Sep 2014 17:05:52 -0400 Subject: handling fallout from entry api --- src/librustdoc/html/render.rs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'src/librustdoc/html') diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 2107854c52b..b9de64bb900 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -34,6 +34,7 @@ //! both occur before the crate is rendered. use std::collections::{HashMap, HashSet}; +use std::collections::hashmap::{Occupied, Vacant}; use std::fmt; use std::io::fs::PathExtensions; use std::io::{fs, File, BufferedWriter, MemWriter, BufferedReader}; @@ -801,9 +802,10 @@ impl DocFolder for Cache { clean::ImplItem(ref i) => { match i.trait_ { Some(clean::ResolvedPath{ did, .. }) => { - let v = self.implementors.find_or_insert_with(did, |_| { - Vec::new() - }); + let v = match self.implementors.entry(did) { + Vacant(entry) => entry.set(Vec::with_capacity(1)), + Occupied(entry) => entry.into_mut(), + }; v.push(Implementor { def_id: item.def_id, generics: i.generics.clone(), @@ -998,9 +1000,10 @@ impl DocFolder for Cache { match did { Some(did) => { - let v = self.impls.find_or_insert_with(did, |_| { - Vec::new() - }); + let v = match self.impls.entry(did) { + Vacant(entry) => entry.set(Vec::with_capacity(1)), + Occupied(entry) => entry.into_mut(), + }; v.push(Impl { impl_: i, dox: dox, @@ -2141,7 +2144,10 @@ fn build_sidebar(m: &clean::Module) -> HashMap> { None => continue, Some(ref s) => s.to_string(), }; - let v = map.find_or_insert_with(short.to_string(), |_| Vec::new()); + let v = match map.entry(short.to_string()) { + Vacant(entry) => entry.set(Vec::with_capacity(1)), + Occupied(entry) => entry.into_mut(), + }; v.push(myname); } -- cgit 1.4.1-3-g733a5