mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-28 12:45:27 +00:00
servo: Merge #4664 - Stop using Vec::from_elem (from Ms2ger:from_elem); r=larsbergstrom
It is obsolete on Rust master. Source-Repo: https://github.com/servo/servo Source-Revision: d747a33df9c167a3defbbdcfe356ee25eeb672ad
This commit is contained in:
parent
b3ff89bc52
commit
ec6187c22f
@ -8,6 +8,7 @@ use servo_util::range::{Range, RangeIndex, EachIndex};
|
||||
use servo_util::geometry::Au;
|
||||
|
||||
use std::cmp::PartialOrd;
|
||||
use std::iter::repeat;
|
||||
use std::num::NumCast;
|
||||
use std::mem;
|
||||
use std::u16;
|
||||
@ -526,7 +527,8 @@ impl<'a> GlyphStore {
|
||||
assert!(length > 0);
|
||||
|
||||
GlyphStore {
|
||||
entry_buffer: Vec::from_elem(length as uint, GlyphEntry::initial()),
|
||||
entry_buffer: repeat(GlyphEntry::initial()).take(length as uint)
|
||||
.collect(),
|
||||
detail_store: DetailedGlyphStore::new(),
|
||||
is_whitespace: is_whitespace,
|
||||
}
|
||||
|
@ -43,6 +43,7 @@ use libc::{c_uint, c_int, c_void, c_char};
|
||||
use servo_util::geometry::Au;
|
||||
use servo_util::range::Range;
|
||||
use std::char;
|
||||
use std::iter::repeat;
|
||||
use std::mem;
|
||||
use std::cmp;
|
||||
use std::ptr;
|
||||
@ -295,9 +296,10 @@ impl Shaper {
|
||||
|
||||
// fast path: all chars are single-byte.
|
||||
if byte_max == char_max {
|
||||
byte_to_glyph = Vec::from_elem(byte_max as uint, NO_GLYPH);
|
||||
byte_to_glyph = repeat(NO_GLYPH).take(byte_max as uint).collect();
|
||||
} else {
|
||||
byte_to_glyph = Vec::from_elem(byte_max as uint, CONTINUATION_BYTE);
|
||||
byte_to_glyph = repeat(CONTINUATION_BYTE).take(byte_max as uint)
|
||||
.collect();
|
||||
for (i, _) in text.char_indices() {
|
||||
byte_to_glyph[i] = NO_GLYPH;
|
||||
}
|
||||
|
@ -44,6 +44,7 @@ use servo_util::geometry::{mod, Au, to_px};
|
||||
use servo_util::logical_geometry::{LogicalPoint, LogicalRect, LogicalSize};
|
||||
use servo_util::opts;
|
||||
use std::default::Default;
|
||||
use std::iter::repeat;
|
||||
use std::num::FloatMath;
|
||||
use style::computed::{AngleOrCorner, LengthOrPercentage, HorizontalDirection, VerticalDirection};
|
||||
use style::computed::{Image, LinearGradient};
|
||||
@ -881,7 +882,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
||||
renderer.deref().lock().send(SendPixelContents(sender));
|
||||
receiver.recv()
|
||||
},
|
||||
None => Vec::from_elem(width * height * 4, 0xFFu8)
|
||||
None => repeat(0xFFu8).take(width * height * 4).collect(),
|
||||
};
|
||||
|
||||
let canvas_display_item = box ImageDisplayItem {
|
||||
|
@ -4584,11 +4584,12 @@ class CGBindingRoot(CGThing):
|
||||
'page::JSPageInfo',
|
||||
'libc',
|
||||
'servo_util::str::DOMString',
|
||||
'std::mem',
|
||||
'std::cmp',
|
||||
'std::iter::repeat',
|
||||
'std::mem',
|
||||
'std::num',
|
||||
'std::ptr',
|
||||
'std::str',
|
||||
'std::num',
|
||||
])
|
||||
|
||||
# Add the auto-generated comment.
|
||||
@ -4885,7 +4886,7 @@ class CallbackMember(CGNativeMember):
|
||||
if self.argCount > 0:
|
||||
replacements["argCount"] = self.argCountStr
|
||||
replacements["argvDecl"] = string.Template(
|
||||
"let mut argv = Vec::from_elem(${argCount}, UndefinedValue());\n"
|
||||
"let mut argv = repeat(UndefinedValue()).take(${argCount}).collect::<Vec<_>>();\n"
|
||||
).substitute(replacements)
|
||||
else:
|
||||
# Avoid weird 0-sized arrays
|
||||
|
@ -6,6 +6,7 @@ use std::collections::HashMap;
|
||||
use std::collections::hash_map::{Occupied, Vacant};
|
||||
use rand::Rng;
|
||||
use std::hash::{Hash, sip};
|
||||
use std::iter::repeat;
|
||||
use std::rand::task_rng;
|
||||
use std::slice::Items;
|
||||
|
||||
@ -148,7 +149,7 @@ impl<K:Clone+PartialEq+Hash,V:Clone> SimpleHashCache<K,V> {
|
||||
pub fn new(cache_size: uint) -> SimpleHashCache<K,V> {
|
||||
let mut r = task_rng();
|
||||
SimpleHashCache {
|
||||
entries: Vec::from_elem(cache_size, None),
|
||||
entries: repeat(None).take(cache_size).collect(),
|
||||
k0: r.gen(),
|
||||
k1: r.gen(),
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user