mirror of
				https://github.com/rust-lang/rust.git
				synced 2025-10-30 20:44:34 +00:00 
			
		
		
		
	 09d5bcf1ad
			
		
	
	
		09d5bcf1ad
		
			
		
	
	
	
	
		
			
			Improve performance of `String` methods by avoiding unnecessary memcpy for the character bytes, with added codegen check to ensure compliance.
		
			
				
	
	
		
			12 lines
		
	
	
		
			309 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
			
		
		
	
	
			12 lines
		
	
	
		
			309 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
| //! Check that `String::push` is optimized enough not to call `memcpy`.
 | |
| 
 | |
| //@ compile-flags: -O
 | |
| #![crate_type = "lib"]
 | |
| 
 | |
| // CHECK-LABEL: @string_push_does_not_call_memcpy
 | |
| #[no_mangle]
 | |
| pub fn string_push_does_not_call_memcpy(s: &mut String, ch: char) {
 | |
|     // CHECK-NOT: call void @llvm.memcpy
 | |
|     s.push(ch);
 | |
| }
 |