Poor implementation of plugin aliasing?

I still don't know enough abut JS, it seems. Usually, compilers tend to optimize functions with a constant outcome, but eval could indeed be different.


Still, i don't think that plugin commands are really an issue here, since they are usually called infrequently and functions like update() would bother me much more. Sadly, i don't think there is a good alternative to aliasing that's generic enough to cover all cases. The best solution is probably not to use too many plugins and for scripters to only alias what they really need and handle as much as possible inside our own functions.
I'll start adding a param to my plugins asking the user if they want me to enable the plugin commands.
I just stumbled over this (not mine): https://jsperf.com/function-calls-direct-vs-apply-vs-call-vs-bind/6

The best solution would be to add the alias as a new function to the prototype (like we did in Ruby) and call it directly. It's obviously important to use unique names, prefixed with your own name and the plugin name, to prevent side effects.

I'll probably handle it kinda like this (not tested at all):

Code:
Class.prototype._iavra || (Class.prototype._iavra = {});                // container to hold all of my aliasesClass.prototype._iavra.pluginName_aliasedFunction = Class.prototype.fn; // aliasClass.prototype.fn = function() {    // do stuff    this._iavra.pluginName_aliasedFunction(arguments);};
/edit: I just realized that we can't use "arguments" in this case, as it will be treated as a single, array-like argument. ES6 introduces the spread operator (...), but it's completely new, so it can't simply be compiled down to ES5. This means, we'll have to know all parameters or need to fall back to using apply().
Ah, that was it!

I wanted to test this earlier, but clicked the "edit" button on the jsperf and forgot what I wanted to do :B

I ran the perf here and .call was the fastest of them all, even faster than directly calling the method, how's that possible?

Original thread: https://forums.rpgmakerweb.com/threads/poor-implementation-of-plugin-aliasing.50237/