Skip to content

Commit

Permalink
Optimize strncmp with a constant string to strcmp
Browse files Browse the repository at this point in the history
Checking length is useless when one of the strings is already fixed width
  • Loading branch information
uyjulian committed Jun 28, 2021
1 parent 6a5be80 commit abd6a6b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion modules/mcemu/imports.lst
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ stdio_IMPORTS_end

sysclib_IMPORTS_start
I_prnt
I_strncmp
I_strcmp
sysclib_IMPORTS_end

sysmem_IMPORTS_start
Expand Down
8 changes: 4 additions & 4 deletions modules/mcemu/mcemu.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ int hookRegisterLibraryEntires(iop_library_t *lib)
{
register int ret;

if (!strncmp(lib->name, "sio2man", 8)) {
if (!strcmp(lib->name, "sio2man")) {
ret = pRegisterLibraryEntires(lib);
if (ret == 0) {
ReleaseLibraryEntries((struct irx_export_table *)lib);
Expand All @@ -252,7 +252,7 @@ int hookRegisterLibraryEntires(iop_library_t *lib)
DPRINTF("registering library %s failed, error %d\n", lib->name, ret);
return ret;
}
} else if (!strncmp(lib->name, "secrman", 8)) {
} else if (!strcmp(lib->name, "secrman")) {
ret = pRegisterLibraryEntires(lib);
if (ret == 0) {
ReleaseLibraryEntries((struct irx_export_table *)lib);
Expand All @@ -262,7 +262,7 @@ int hookRegisterLibraryEntires(iop_library_t *lib)
DPRINTF("registering library %s failed, error %d\n", lib->name, ret);
return ret;
}
} else if (!strncmp(lib->name, "mcman", 8)) {
} else if (!strcmp(lib->name, "mcman")) {
ret = pRegisterLibraryEntires(lib);
if (ret == 0) {
ReleaseLibraryEntries((struct irx_export_table *)lib);
Expand All @@ -274,7 +274,7 @@ int hookRegisterLibraryEntires(iop_library_t *lib)
return ret;
}
#ifdef PADEMU
} else if (!strncmp(lib->name, "pademu", 8)) {
} else if (!strcmp(lib->name, "pademu")) {
pademu_hookSio2man = GetExportEntry(&lib[1], 4);
#endif
}
Expand Down

0 comments on commit abd6a6b

Please sign in to comment.