@@ -210,10 +210,13 @@ pub static RUNTIME: LazyLock<HashMap<String, RuntimeFunc>> =
210210 } ) ;
211211
212212impl ScriptWorker {
213- fn jit_instruction ( name : String , arg : Arg , ctx : & BuildContext ) {
213+ fn jit_instruction ( name : & CStr , arg : Arg , ctx : & BuildContext ) {
214214 let mut arg_ptr = Self :: get_arg_value ( arg, ctx) ;
215215
216- let ( func, func_type) = ctx. module_runtime . get ( & name) . unwrap ( ) ;
216+ let ( func, func_type) = ctx
217+ . module_runtime
218+ . get ( name. to_str ( ) . expect ( "Couldn't convert name to string" ) )
219+ . unwrap ( ) ;
217220
218221 unsafe {
219222 LLVMBuildCall2 (
@@ -222,7 +225,7 @@ impl ScriptWorker {
222225 * func,
223226 & mut arg_ptr,
224227 1 ,
225- name. as_str ( ) . as_ptr ( ) as * const _ ,
228+ name. as_ptr ( ) as * const _ ,
226229 ) ;
227230 }
228231 }
@@ -320,7 +323,8 @@ impl ScriptWorker {
320323 & mut err,
321324 ) != 0
322325 {
323- // In case of error, we must avoid using the uninitialized ExecutionEngineRef.
326+ // In case of error, we must avoid using the uninitialized
327+ // ExecutionEngineRef.
324328 assert ! ( !err. is_null( ) ) ;
325329 panic ! (
326330 "Failed to create execution engine: {:?}" ,
@@ -385,8 +389,8 @@ impl ScriptWorker {
385389 function_type,
386390 ) ;
387391
388- // Create a basic block in the function and set our builder to generate
389- // code in it.
392+ // Create a basic block in the function and set our builder to
393+ // generate code in it.
390394 let bb = LLVMAppendBasicBlockInContext (
391395 context,
392396 function,
@@ -425,30 +429,22 @@ impl ScriptWorker {
425429 // JIT the instruction and collect it's name
426430 let name = match instr. clone ( ) {
427431 Instruction :: Task { name, args : _ } => {
428- Self :: jit_instruction ( String :: from ( "task" ) , name, & ctx) ;
432+ Self :: jit_instruction ( c "task", name, & ctx) ;
429433 "task"
430434 }
431435
432436 Instruction :: Open { path } => {
433- Self :: jit_instruction ( String :: from ( "open" ) , path, & ctx) ;
437+ Self :: jit_instruction ( c "open", path, & ctx) ;
434438 "open"
435439 }
436440
437441 Instruction :: Ping { server } => {
438- Self :: jit_instruction (
439- String :: from ( "ping" ) ,
440- server,
441- & ctx,
442- ) ;
442+ Self :: jit_instruction ( c"ping" , server, & ctx) ;
443443 "ping"
444444 }
445445
446446 Instruction :: Debug { text } => {
447- Self :: jit_instruction (
448- String :: from ( "debug" ) ,
449- text,
450- & ctx,
451- ) ;
447+ Self :: jit_instruction ( c"debug" , text, & ctx) ;
452448 "debug"
453449 }
454450 } ;
0 commit comments