mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
Stop using Vec::from_elem.
It is obsolete on Rust master.
This commit is contained in:
parent
60a901328a
commit
05c4e3b9f5
5 changed files with 15 additions and 8 deletions
|
@ -8,6 +8,7 @@ use servo_util::range::{Range, RangeIndex, EachIndex};
|
||||||
use servo_util::geometry::Au;
|
use servo_util::geometry::Au;
|
||||||
|
|
||||||
use std::cmp::PartialOrd;
|
use std::cmp::PartialOrd;
|
||||||
|
use std::iter::repeat;
|
||||||
use std::num::NumCast;
|
use std::num::NumCast;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::u16;
|
use std::u16;
|
||||||
|
@ -526,7 +527,8 @@ impl<'a> GlyphStore {
|
||||||
assert!(length > 0);
|
assert!(length > 0);
|
||||||
|
|
||||||
GlyphStore {
|
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(),
|
detail_store: DetailedGlyphStore::new(),
|
||||||
is_whitespace: is_whitespace,
|
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::geometry::Au;
|
||||||
use servo_util::range::Range;
|
use servo_util::range::Range;
|
||||||
use std::char;
|
use std::char;
|
||||||
|
use std::iter::repeat;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::cmp;
|
use std::cmp;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
|
@ -295,9 +296,10 @@ impl Shaper {
|
||||||
|
|
||||||
// fast path: all chars are single-byte.
|
// fast path: all chars are single-byte.
|
||||||
if byte_max == char_max {
|
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 {
|
} 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() {
|
for (i, _) in text.char_indices() {
|
||||||
byte_to_glyph[i] = NO_GLYPH;
|
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::logical_geometry::{LogicalPoint, LogicalRect, LogicalSize};
|
||||||
use servo_util::opts;
|
use servo_util::opts;
|
||||||
use std::default::Default;
|
use std::default::Default;
|
||||||
|
use std::iter::repeat;
|
||||||
use std::num::FloatMath;
|
use std::num::FloatMath;
|
||||||
use style::computed::{AngleOrCorner, LengthOrPercentage, HorizontalDirection, VerticalDirection};
|
use style::computed::{AngleOrCorner, LengthOrPercentage, HorizontalDirection, VerticalDirection};
|
||||||
use style::computed::{Image, LinearGradient};
|
use style::computed::{Image, LinearGradient};
|
||||||
|
@ -881,7 +882,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
||||||
renderer.deref().lock().send(SendPixelContents(sender));
|
renderer.deref().lock().send(SendPixelContents(sender));
|
||||||
receiver.recv()
|
receiver.recv()
|
||||||
},
|
},
|
||||||
None => Vec::from_elem(width * height * 4, 0xFFu8)
|
None => repeat(0xFFu8).take(width * height * 4).collect(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let canvas_display_item = box ImageDisplayItem {
|
let canvas_display_item = box ImageDisplayItem {
|
||||||
|
|
|
@ -4584,11 +4584,12 @@ class CGBindingRoot(CGThing):
|
||||||
'page::JSPageInfo',
|
'page::JSPageInfo',
|
||||||
'libc',
|
'libc',
|
||||||
'servo_util::str::DOMString',
|
'servo_util::str::DOMString',
|
||||||
'std::mem',
|
|
||||||
'std::cmp',
|
'std::cmp',
|
||||||
|
'std::iter::repeat',
|
||||||
|
'std::mem',
|
||||||
|
'std::num',
|
||||||
'std::ptr',
|
'std::ptr',
|
||||||
'std::str',
|
'std::str',
|
||||||
'std::num',
|
|
||||||
])
|
])
|
||||||
|
|
||||||
# Add the auto-generated comment.
|
# Add the auto-generated comment.
|
||||||
|
@ -4885,7 +4886,7 @@ class CallbackMember(CGNativeMember):
|
||||||
if self.argCount > 0:
|
if self.argCount > 0:
|
||||||
replacements["argCount"] = self.argCountStr
|
replacements["argCount"] = self.argCountStr
|
||||||
replacements["argvDecl"] = string.Template(
|
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)
|
).substitute(replacements)
|
||||||
else:
|
else:
|
||||||
# Avoid weird 0-sized arrays
|
# Avoid weird 0-sized arrays
|
||||||
|
|
|
@ -6,6 +6,7 @@ use std::collections::HashMap;
|
||||||
use std::collections::hash_map::{Occupied, Vacant};
|
use std::collections::hash_map::{Occupied, Vacant};
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
use std::hash::{Hash, sip};
|
use std::hash::{Hash, sip};
|
||||||
|
use std::iter::repeat;
|
||||||
use std::rand::task_rng;
|
use std::rand::task_rng;
|
||||||
use std::slice::Items;
|
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> {
|
pub fn new(cache_size: uint) -> SimpleHashCache<K,V> {
|
||||||
let mut r = task_rng();
|
let mut r = task_rng();
|
||||||
SimpleHashCache {
|
SimpleHashCache {
|
||||||
entries: Vec::from_elem(cache_size, None),
|
entries: repeat(None).take(cache_size).collect(),
|
||||||
k0: r.gen(),
|
k0: r.gen(),
|
||||||
k1: r.gen(),
|
k1: r.gen(),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue