Skip to content

CharacterSource #6

Description

@willmotil

jjag i was just looking over your changes again.

Previously you mentioned font description needed work but it appears you have already changed it over to ints from char.

Anyways the post title.
I think i get the idea for the getutf32(...) function to localize the code. but it is going to hurt performance to make another method call in the for loop especially with that yield.

This is what i came up with i think its probably faster.
(1) a assignment
(2) a conditional test.

            for (int i = 0; i < text.Length; i++)
            {
                char cs = text[i];
                int charval = cs;  // (1)
                if (char.IsHighSurrogate(cs))   // (2)
                {
                    // if we do end up in here we get to skip a entire character calculation next pass so this is essentially a speed improvement.
                    charval = char.ConvertToUtf32(cs, text[i + 1]); 
                    i++;
                }

                if (charval == '\r')
                    continue;

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions