Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimization potential in LanguageFilter::Init #1076

Open
xezon opened this issue Feb 3, 2024 · 0 comments
Open

Optimization potential in LanguageFilter::Init #1076

xezon opened this issue Feb 3, 2024 · 0 comments

Comments

@xezon
Copy link
Contributor

xezon commented Feb 3, 2024

void LanguageFilter::Init()
{
    m_wordList.clear();

    File *file = g_theFileSystem->Open_File("langdata.dat", File::READ | File::BINARY);

    if (file != nullptr) {
        unichar_t buf[128];

        while (Read_Word(file, buf)) {
            int len = u_strlen(buf); // Get rid of this

            if (len != 0) {
                for (int i = 0; i < len; i++) {
                    buf[i] ^= 0x5555;
                }

                Utf16String str(buf);
                Un_Haxor(str);
                m_wordList[str] = true;
            }
        }

        file->Close();
    }
}

We can get rid of int len = u_strlen(buf) by having Read_Word return the word count and then use that as len instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant