From f81c0f501c1747d724e90b1a2b26c6f6d1558fc0 Mon Sep 17 00:00:00 2001 From: 0xilis <109871561+0xilis@users.noreply.github.com> Date: Fri, 17 Nov 2023 14:18:26 -0500 Subject: [PATCH] internal backend optimizations described in https://github.com/theos/logos/pull/108. PR'd so this can also be instantly merged when the PR is accepted assuming if everything in that PR is fine. --- Sources/Orion/InternalBackend.swift | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/Sources/Orion/InternalBackend.swift b/Sources/Orion/InternalBackend.swift index cbc3a75..c602000 100644 --- a/Sources/Orion/InternalBackend.swift +++ b/Sources/Orion/InternalBackend.swift @@ -38,14 +38,8 @@ extension Backends.Internal { let imp = IMP(replacement) let orig: IMP - // first try to add the method (in case the current imp is inherited) - if class_addMethod(cls, sel, imp, types) { - // if added, return the super imp - orig = method_getImplementation(origMethod) - } else { - // otherwise, the current class has its own imp of the method. Replace it. - orig = method_setImplementation(origMethod, imp) - } + // class_replaceMethod adds the method if it's implemented by the superclass so no need to replicate this behavior + orig = class_replaceMethod(cls, sel, imp, types); return .init(orig) }