geekbozu / NintendoWiSpy

A live input-viewer for GameCube/N64 controllers over wifi or usb serial. Used for showing/recording inputs during livestreams/gameplay recording sessions.
MIT License
4 stars 2 forks source link

Optimize extractControls #10

Closed Eeems closed 6 years ago

Eeems commented 6 years ago

Instead of declaring ret as an empty object, and then initializing it's properties I would suggest doing the following:

var button = {},
    analog = {};
// Code here
return {
    button: button,
    analog: analog
};

This way you can also shorted up the rest of your code instead of having to use ret.button. or ret.analog. I've updated my older optimization snippet to include this concept (https://www.irccloud.com/pastebin/zvPElZLJ/).

geekbozu commented 6 years ago

See #11