Skip to content

Commit c335e5b

Browse files
committed
---
yaml --- r: 20725 b: refs/heads/snap-stage3 c: 68e9aa5 h: refs/heads/master i: 20723: ea7776a v: v3
1 parent 0f296bd commit c335e5b

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: e430a699f2c60890d9b86069fd0c68a70ece7120
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 519deca7168713a141e7341315a98b35e1f55ef2
4+
refs/heads/snap-stage3: 68e9aa5fcbfbb1b5e87c667372ac7212746779c0
55
refs/heads/try: ffbe0e0e00374358b789b0037bcb3a577cd218be
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/libcore/at_vec.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,25 +131,33 @@ mod unsafe {
131131
(**repr).fill = new_len * sys::size_of::<T>();
132132
}
133133

134-
/// Append an element to a vector
135134
#[inline(always)]
136135
unsafe fn push<T>(&v: @[const T], +initval: T) {
137136
let repr: **vec_repr = ::unsafe::reinterpret_cast(addr_of(v));
138137
let fill = (**repr).fill;
139138
if (**repr).alloc > fill {
140-
(**repr).fill += sys::size_of::<T>();
141-
let p = addr_of((**repr).data);
142-
let p = ptr::offset(p, fill) as *mut T;
143-
rusti::move_val_init(*p, initval);
139+
push_fast(v, initval);
144140
}
145141
else {
146142
push_slow(v, initval);
147143
}
148144
}
145+
// This doesn't bother to make sure we have space.
146+
#[inline(always)] // really pretty please
147+
unsafe fn push_fast<T>(&v: @[const T], +initval: T) {
148+
let repr: **vec_repr = ::unsafe::reinterpret_cast(addr_of(v));
149+
let fill = (**repr).fill;
150+
(**repr).fill += sys::size_of::<T>();
151+
let p = ptr::addr_of((**repr).data);
152+
let p = ptr::offset(p, fill) as *mut T;
153+
rusti::move_val_init(*p, initval);
154+
}
155+
149156
unsafe fn push_slow<T>(&v: @[const T], +initval: T) {
150157
reserve_at_least(v, v.len() + 1u);
151-
push(v, initval);
158+
push_fast(v, initval);
152159
}
160+
153161
/**
154162
* Reserves capacity for exactly `n` elements in the given vector.
155163
*

0 commit comments

Comments
 (0)