Skip to content

Commit

Permalink
(glslang_utill.c) One less string copy per iteration
Browse files Browse the repository at this point in the history
  • Loading branch information
LibretroAdmin committed Jan 17, 2025
1 parent 1975235 commit a9b0e45
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
2 changes: 1 addition & 1 deletion file_path_special.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ bool fill_pathname_application_data(char *s, size_t len)
if (appdata)
{
fill_pathname_join(s, appdata,
"Library/Application Support/RetroArch", len);
"Library/Application Support/RetroArch", len);
return true;
}
#endif
Expand Down
18 changes: 6 additions & 12 deletions gfx/drivers_shader/glslang_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@
#include "glslang_util.h"
#include "../../verbosity.h"

static void get_include_file(const char *line, char *s, size_t len)
static char *slang_get_include_file(const char *line)
{
char *end = NULL;
char *start = (char*)strchr(line, '\"');
if (!start)
return;
return NULL;
start++;
if (!(end = (char*)strchr(start, '\"')))
return;
return NULL;
*end = '\0';
strlcpy(s, start, len);
return start;
}

bool slang_texture_semantic_is_array(enum slang_texture_semantic sem)
Expand Down Expand Up @@ -193,22 +193,16 @@ bool glslang_read_shader_file(const char *path,
bool include_optional = !strncmp("#pragma include_optional ", line, STRLEN_CONST("#pragma include_optional "));
if ( !strncmp("#include ", line, STRLEN_CONST("#include ")) || include_optional )
{

char include_file[PATH_MAX_LENGTH];
char include_path[PATH_MAX_LENGTH];

include_file[0] = '\0';
include_path[0] = '\0';

/* Build include file path */
get_include_file(line, include_file, sizeof(include_file));
char *include_file = slang_get_include_file(line);

if (string_is_empty(include_file))
{
RARCH_ERR("[slang]: Invalid include statement \"%s\".\n", line);
goto error;
}

include_path[0] = '\0';
fill_pathname_resolve_relative(
include_path, path, include_file, sizeof(include_path));

Expand Down
2 changes: 1 addition & 1 deletion libretro-common/encodings/encoding_utf.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ size_t utf8cpy(char *d, size_t d_len, const char *s, size_t chars)
sb++;
}

if ((size_t)(sb - sb_org) > d_len-1 /* NUL */)
if ((size_t)(sb - sb_org) > d_len-1)
{
sb = sb_org + d_len-1;
while ((*sb & 0xC0) == 0x80)
Expand Down

0 comments on commit a9b0e45

Please sign in to comment.