File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -462,13 +462,15 @@ fn main() {
462462 bindings. write ( Box :: new ( & mut bindings_string) ) . expect ( "Couldn't write bindings!" ) ;
463463
464464 // Use i32 for this type since that's what the assembler APIs expect
465- const JIT_CONSTANTS_NEEDLE : & str = "\n pub type jit_bindgen_constants = u32;\n " ;
466- const JIT_CONSTANTS_REPLACEMENT : & [ u8 ] = b"\n pub type jit_bindgen_constants = i32;\n " ;
467- // Yes, this search and replace could be faster, but it's a small file.
468- let bindings_str = str:: from_utf8 ( bindings_string. as_ref ( ) ) . expect ( "bindings should be in UTF-8" ) ;
469- let type_needle_start = bindings_str. find ( JIT_CONSTANTS_NEEDLE ) . expect ( "bindings should have jit_bindgen_constants" ) ;
470- ( & mut bindings_string[ type_needle_start..type_needle_start + JIT_CONSTANTS_NEEDLE . len ( ) ] )
471- . copy_from_slice ( JIT_CONSTANTS_REPLACEMENT ) ;
465+ const JIT_CONSTANTS_NEEDLE : & [ u8 ] = b"pub type jit_bindgen_constants = u32;" ;
466+ const JIT_CONSTANTS_REPLACEMENT : & [ u8 ] = b"pub type jit_bindgen_constants = i32;" ;
467+ // Yes, this search-and-replace could be faster, but it's a small file.
468+ for line in bindings_string. as_mut_slice ( ) . split_mut ( |& byte| byte == b'\n' ) {
469+ if line == JIT_CONSTANTS_NEEDLE {
470+ line. copy_from_slice ( JIT_CONSTANTS_REPLACEMENT ) ;
471+ break ;
472+ }
473+ }
472474
473475 // Write out to file
474476 let mut out_path: PathBuf = src_root;
You can’t perform that action at this time.
0 commit comments