Skip to content

Remove StrCaseStr utility from StringUtil.h #3061

Description

@Nouridin

I was reviewing rts/System/StringUtil.h, I saw that StrCaseStr is inline function along with two global static buffers

static char lcstr[32768];
static char lcsub[32768];
static inline const char* StrCaseStr(const char* str, const char* sub) {
	const char* pos = nullptr;

	if (str == nullptr)
		return nullptr;
	if (sub == nullptr)
		return nullptr;

	std::strncpy(lcstr, str, sizeof(lcstr) - 1);
	std::strncpy(lcsub, sub, sizeof(lcsub) - 1);
	std::transform(lcstr, lcstr + sizeof(lcstr), lcstr, (int (*)(int)) tolower);
	std::transform(lcsub, lcsub + sizeof(lcsub), lcsub, (int (*)(int)) tolower);

	if ((pos = std::strstr(lcstr, lcsub)) == nullptr)
		return nullptr;

	return (str + (pos - lcstr));
}

i think we would remove lcstr,lcsub,StrCaseStr
and refactor the single usage in CMiniMap::ConfigCommand to use hashStringLower

if you think it is a good idea assign the task to me and i will do it asap

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions