From 5c16065169fe4ad8085bcd5ff51752306d0f58ff Mon Sep 17 00:00:00 2001 From: LingMan <18294-LingMan@users.noreply.gitlab.freedesktop.org> Date: Wed, 5 Oct 2022 23:36:53 +0200 Subject: [PATCH] rusticl/api: Don't check the program source for nul bytes needlessly At this point we already know that the Vec we've constructed cannot contain a nul byte. Avoid the needless scan. Part-of: --- src/gallium/frontends/rusticl/api/program.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gallium/frontends/rusticl/api/program.rs b/src/gallium/frontends/rusticl/api/program.rs index 52dee61..eaa6e35 100644 --- a/src/gallium/frontends/rusticl/api/program.rs +++ b/src/gallium/frontends/rusticl/api/program.rs @@ -159,7 +159,8 @@ pub fn create_program_with_source( Ok(cl_program::from_arc(Program::new( &c, &c.devs, - CString::new(source).map_err(|_| CL_INVALID_VALUE)?, + // SAFETY: We've constructed `source` such that it contains no nul bytes. + unsafe { CString::from_vec_unchecked(source) }, ))) } -- 2.7.4