about summary refs log tree commit diff
path: root/src/liballoc/string.rs
diff options
context:
space:
mode:
authorkennytm <kennytm@gmail.com>2018-08-21 22:05:30 +0800
committerkennytm <kennytm@gmail.com>2018-08-21 22:05:30 +0800
commit0dd88c97975b2a2e4ea3e4a2bdc3670a9f40bd67 (patch)
tree0ad62b121fcafe2d11ee95819caf64e975d4ad00 /src/liballoc/string.rs
parent9bbab65ebefbeb512445a759603b03f858e5e9b9 (diff)
parent993fb934640b7e514f3c629c33a2698a83ed8c3e (diff)
downloadrust-0dd88c97975b2a2e4ea3e4a2bdc3670a9f40bd67.tar.gz
rust-0dd88c97975b2a2e4ea3e4a2bdc3670a9f40bd67.zip
Rollup merge of #53329 - frewsxcv:frewsxcv-ptr-add-sub, r=RalfJung
Replace usages of ptr::offset with ptr::{add,sub}.

Rust provides these helper methods – so let's use them!
Diffstat (limited to 'src/liballoc/string.rs')
-rw-r--r--src/liballoc/string.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/liballoc/string.rs b/src/liballoc/string.rs
index dd559df08cc..eabda7123de 100644
--- a/src/liballoc/string.rs
+++ b/src/liballoc/string.rs
@@ -1190,8 +1190,8 @@ impl String {
         let next = idx + ch.len_utf8();
         let len = self.len();
         unsafe {
-            ptr::copy(self.vec.as_ptr().offset(next as isize),
-                      self.vec.as_mut_ptr().offset(idx as isize),
+            ptr::copy(self.vec.as_ptr().add(next),
+                      self.vec.as_mut_ptr().add(idx),
                       len - next);
             self.vec.set_len(len - (next - idx));
         }
@@ -1232,8 +1232,8 @@ impl String {
                 del_bytes += ch_len;
             } else if del_bytes > 0 {
                 unsafe {
-                    ptr::copy(self.vec.as_ptr().offset(idx as isize),
-                              self.vec.as_mut_ptr().offset((idx - del_bytes) as isize),
+                    ptr::copy(self.vec.as_ptr().add(idx),
+                              self.vec.as_mut_ptr().add(idx - del_bytes),
                               ch_len);
                 }
             }
@@ -1289,11 +1289,11 @@ impl String {
         let amt = bytes.len();
         self.vec.reserve(amt);
 
-        ptr::copy(self.vec.as_ptr().offset(idx as isize),
-                  self.vec.as_mut_ptr().offset((idx + amt) as isize),
+        ptr::copy(self.vec.as_ptr().add(idx),
+                  self.vec.as_mut_ptr().add(idx + amt),
                   len - idx);
         ptr::copy(bytes.as_ptr(),
-                  self.vec.as_mut_ptr().offset(idx as isize),
+                  self.vec.as_mut_ptr().add(idx),
                   amt);
         self.vec.set_len(len + amt);
     }