1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 08:27:35 +00:00

Userland: Change static const variables to static constexpr

`static const` variables can be computed and initialized at run-time
during initialization or the first time a function is called. Change
them to `static constexpr` to ensure they are computed at
compile-time.

This allows some removal of `strlen` because the length of the
`StringView` can be used which is pre-computed at compile-time.
This commit is contained in:
Lenny Maiorani 2022-03-13 16:09:41 -06:00 committed by Andreas Kling
parent 31515a9147
commit f912a48315
23 changed files with 111 additions and 82 deletions

View file

@ -1,9 +1,11 @@
/*
* Copyright (c) 2022, Sahan Fernando <sahan.h.fernando@gmail.com>
* Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/StringView.h>
#include <Kernel/API/VirGL.h>
#include <sys/ioctl_numbers.h>
@ -235,9 +237,9 @@ void CommandBufferBuilder::append_set_constant_buffer(Vector<float> const& const
}
}
void CommandBufferBuilder::append_create_shader(ObjectHandle handle, Gallium::ShaderType shader_type, const char* shader_data)
void CommandBufferBuilder::append_create_shader(ObjectHandle handle, Gallium::ShaderType shader_type, StringView shader_data)
{
size_t shader_len = strlen(shader_data) + 1; // Need to remember to copy null terminator as well if needed
size_t shader_len = shader_data.length() + 1; // Need to remember to copy null terminator as well if needed
CommandBuilder builder(m_buffer, Protocol::VirGLCommand::CREATE_OBJECT, to_underlying(Protocol::ObjectType::SHADER));
builder.appendu32(handle.value()); // VIRGL_OBJ_CREATE_HANDLE
builder.appendu32(to_underlying(shader_type));