Skip to content

Commit afc4b09

Browse files
committed
Remove allocation in FromSql for IpAddr
1 parent 3ac26d4 commit afc4b09

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/types/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,9 @@ impl RawFromSql for IpAddr {
548548
let _bits = try!(raw.read_u8());
549549
let _is_cidr = try!(raw.read_u8());
550550
let nb = try!(raw.read_u8());
551-
let mut buf = &*try!(raw.read_exact(nb as uint));
551+
let mut buf: &mut [u8] = &mut [0u8, ..16];
552+
try!(raw.read_at_least(nb as uint, buf));
553+
let mut buf: &[u8] = buf;
552554

553555
match family {
554556
2 if nb == 4 => Ok(IpAddr::Ipv4Addr(buf[0], buf[1], buf[2], buf[3])),

0 commit comments

Comments
 (0)