mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
Replace truncate(0) with clear()
This commit is contained in:
@@ -702,7 +702,7 @@ fn compress(&mut self, mut outcome_cb: impl FnMut(&O)) {
|
||||
self.apply_rewrites(&node_rewrites);
|
||||
}
|
||||
|
||||
node_rewrites.truncate(0);
|
||||
node_rewrites.clear();
|
||||
self.reused_node_vec = node_rewrites;
|
||||
}
|
||||
|
||||
|
||||
@@ -349,7 +349,7 @@ fn process_obligation(
|
||||
&mut self,
|
||||
pending_obligation: &mut PendingPredicateObligation<'tcx>,
|
||||
) -> ProcessResult<PendingPredicateObligation<'tcx>, FulfillmentErrorCode<'tcx>> {
|
||||
pending_obligation.stalled_on.truncate(0);
|
||||
pending_obligation.stalled_on.clear();
|
||||
|
||||
let obligation = &mut pending_obligation.obligation;
|
||||
|
||||
|
||||
@@ -391,16 +391,16 @@ fn test_read_until() {
|
||||
let mut v = Vec::new();
|
||||
reader.read_until(0, &mut v).unwrap();
|
||||
assert_eq!(v, [0]);
|
||||
v.truncate(0);
|
||||
v.clear();
|
||||
reader.read_until(2, &mut v).unwrap();
|
||||
assert_eq!(v, [1, 2]);
|
||||
v.truncate(0);
|
||||
v.clear();
|
||||
reader.read_until(1, &mut v).unwrap();
|
||||
assert_eq!(v, [1]);
|
||||
v.truncate(0);
|
||||
v.clear();
|
||||
reader.read_until(8, &mut v).unwrap();
|
||||
assert_eq!(v, [0]);
|
||||
v.truncate(0);
|
||||
v.clear();
|
||||
reader.read_until(9, &mut v).unwrap();
|
||||
assert_eq!(v, []);
|
||||
}
|
||||
@@ -429,13 +429,13 @@ fn test_read_line() {
|
||||
let mut s = String::new();
|
||||
reader.read_line(&mut s).unwrap();
|
||||
assert_eq!(s, "a\n");
|
||||
s.truncate(0);
|
||||
s.clear();
|
||||
reader.read_line(&mut s).unwrap();
|
||||
assert_eq!(s, "b\n");
|
||||
s.truncate(0);
|
||||
s.clear();
|
||||
reader.read_line(&mut s).unwrap();
|
||||
assert_eq!(s, "c");
|
||||
s.truncate(0);
|
||||
s.clear();
|
||||
reader.read_line(&mut s).unwrap();
|
||||
assert_eq!(s, "");
|
||||
}
|
||||
|
||||
@@ -17,10 +17,10 @@ fn read_until() {
|
||||
let mut v = Vec::new();
|
||||
assert_eq!(buf.read_until(b'3', &mut v).unwrap(), 3);
|
||||
assert_eq!(v, b"123");
|
||||
v.truncate(0);
|
||||
v.clear();
|
||||
assert_eq!(buf.read_until(b'3', &mut v).unwrap(), 1);
|
||||
assert_eq!(v, b"3");
|
||||
v.truncate(0);
|
||||
v.clear();
|
||||
assert_eq!(buf.read_until(b'3', &mut v).unwrap(), 0);
|
||||
assert_eq!(v, []);
|
||||
}
|
||||
@@ -80,10 +80,10 @@ fn read_line() {
|
||||
let mut v = String::new();
|
||||
assert_eq!(buf.read_line(&mut v).unwrap(), 3);
|
||||
assert_eq!(v, "12\n");
|
||||
v.truncate(0);
|
||||
v.clear();
|
||||
assert_eq!(buf.read_line(&mut v).unwrap(), 1);
|
||||
assert_eq!(v, "\n");
|
||||
v.truncate(0);
|
||||
v.clear();
|
||||
assert_eq!(buf.read_line(&mut v).unwrap(), 0);
|
||||
assert_eq!(v, "");
|
||||
}
|
||||
|
||||
@@ -1364,7 +1364,7 @@ fn _push(&mut self, path: &Path) {
|
||||
|
||||
// absolute `path` replaces `self`
|
||||
if need_clear {
|
||||
self.inner.truncate(0);
|
||||
self.inner.clear();
|
||||
|
||||
// verbatim paths need . and .. removed
|
||||
} else if comps.prefix_verbatim() && !path.inner.is_empty() {
|
||||
|
||||
@@ -93,7 +93,7 @@ fn parse_lp_cmd_line(code_units: &[u16]) -> Option<Vec<OsString>> {
|
||||
// If not `in_quotes`, a space or tab ends the argument.
|
||||
SPACE if !in_quotes => {
|
||||
ret_val.push(OsString::from(&cur[..]));
|
||||
cur.truncate(0);
|
||||
cur.clear();
|
||||
|
||||
// Skip whitespace.
|
||||
while code_units_iter.next_if_eq(&Ok(SPACE)).is_some() {}
|
||||
|
||||
@@ -106,7 +106,7 @@ fn parse_lp_cmd_line<'a, F: Fn() -> OsString>(
|
||||
// If not `in_quotes`, a space or tab ends the argument.
|
||||
SPACE | TAB if !in_quotes => {
|
||||
ret_val.push(OsString::from_wide(&cur[..]));
|
||||
cur.truncate(0);
|
||||
cur.clear();
|
||||
|
||||
// Skip whitespace.
|
||||
code_units.advance_while(|w| w == SPACE || w == TAB);
|
||||
|
||||
@@ -191,7 +191,7 @@ fn run_debuginfo_gdb_test(&self) {
|
||||
let mut stdout = BufReader::new(adb.stdout.take().unwrap());
|
||||
let mut line = String::new();
|
||||
loop {
|
||||
line.truncate(0);
|
||||
line.clear();
|
||||
stdout.read_line(&mut line).unwrap();
|
||||
if line.starts_with("Listening on port 5039") {
|
||||
break;
|
||||
|
||||
@@ -211,12 +211,12 @@ fn handle_run(socket: TcpStream, work: &Path, tmp: &Path, lock: &Mutex<()>, conf
|
||||
let mut args = Vec::new();
|
||||
while t!(reader.read_until(0, &mut arg)) > 1 {
|
||||
args.push(t!(str::from_utf8(&arg[..arg.len() - 1])).to_string());
|
||||
arg.truncate(0);
|
||||
arg.clear();
|
||||
}
|
||||
|
||||
// Next we'll get a bunch of env vars in pairs delimited by 0s as well
|
||||
let mut env = Vec::new();
|
||||
arg.truncate(0);
|
||||
arg.clear();
|
||||
while t!(reader.read_until(0, &mut arg)) > 1 {
|
||||
let key_len = arg.len() - 1;
|
||||
let val_len = t!(reader.read_until(0, &mut arg)) - 1;
|
||||
@@ -227,7 +227,7 @@ fn handle_run(socket: TcpStream, work: &Path, tmp: &Path, lock: &Mutex<()>, conf
|
||||
let val = t!(str::from_utf8(val)).to_string();
|
||||
env.push((key, val));
|
||||
}
|
||||
arg.truncate(0);
|
||||
arg.clear();
|
||||
}
|
||||
|
||||
// The section of code from here down to where we drop the lock is going to
|
||||
|
||||
Reference in New Issue
Block a user