Drakulix / ScrollsModLoader

A Mod Loader Framework for the game "Scrolls" by Mojang
www.scrollsguide.com/summoner
GNU Lesser General Public License v2.1
15 stars 9 forks source link

Do not call `GetHooks` on every method invocation. #2

Closed MaPePeR closed 11 years ago

MaPePeR commented 11 years ago

I'm not sure if anyone already uses dynamic Hooks and i'm also very unsure about if they actually work, because you need to patch the assembly before the hook actually works.

So it would be much better to just call GetHooks once and then have a HashMap-Lookup instead of some code, that calls GetHooks three times (*) on every Mod for every hooked (and hook-injected) method.

(*) Line 59, Line 89, Line 143 in ScrollsModLoader.ModInterceptor.Intercept

Drakulix commented 11 years ago

Yeah there is definitely some improvement possible in that aspect. I am currently on holidays, so you will not see improvements very soon, but I have that on my to-do list. Feel free to fork and fix that yourself, if you don't wanna wait some weeks, I will close and comment this issue, when solved. Also thanks for the wiki pages, I appreciate your contributions and interest in this project.

Greetings

MaPePeR commented 11 years ago

my first try in implementing the Interceptor without calling GetHooks everytime: https://github.com/MaPePeR/ScrollsModLoader/commit/10f5a7a64efb855240832c8474737e8cda93731a?w=1

could not yet test it, maybe because i try to install it into an already patched scrolls - will do that tomorrow. (When starting it says Scrolls is already running, but it isn't)