Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

Big performance issue #23

Open
juanmuscaria opened this issue Mar 6, 2021 · 1 comment
Open

Big performance issue #23

juanmuscaria opened this issue Mar 6, 2021 · 1 comment

Comments

@juanmuscaria
Copy link

Calling Thread.currentThread().getStackTrace(); causes a big performance drop specially the situation you have multiple objects capable of rendering text making it the main hotspot.
screenshot
The project is way too big for me to load it and try to find an work around and do some testings

@juanmuscaria
Copy link
Author

I made a small mixin to patch the method and seems like using a different way to get the calling classes (in this case I'm using WhoCalled) seems to fix the issue, but I don't know how it could be implemented in a more dynamic way
image

@Pseudo
@Mixin(EmojiFontRenderer.class)
public class MixinEmojiFontRenderer {
    @Shadow
    private static EmojiContext CurrentContext;
    @Overwrite(remap = false)
    public static String updateEmojiContext(String text) {
        if (EmojicordConfig.spec.isAvailable() && EmojicordConfig.RENDER.renderEnabled.get()) {
            EnumSet<EmojiContext.EmojiContextAttribute> attributes = EnumSet.noneOf(EmojiContext.EmojiContextAttribute.class);
            if (WhoCalled.$.isCalledByClass(net.minecraft.client.gui.GuiChat.class)) {
                attributes.add(EmojiContext.EmojiContextAttribute.CHAT_INPUT);
            }
            if (WhoCalled.$.isCalledByClass(net.minecraft.client.gui.GuiNewChat.class)) {
                attributes.add(EmojiContext.EmojiContextAttribute.CHAT_MESSAGE);
            }
            CurrentContext = EmojiContext.EmojiContextCache.instance.getContext(text, attributes);
            return CurrentContext.text;
        } else {
            CurrentContext = null;
            return text;
        }
    }
}

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

No branches or pull requests

1 participant