mixpanel / mixpanel-swift

Official iOS (Swift) Tracking Library for Mixpanel Analytics
https://mixpanel.com
Apache License 2.0
434 stars 234 forks source link

Move to static funcs instead of class funcs #360

Closed RamblinWreck77 closed 4 years ago

RamblinWreck77 commented 4 years ago

Class funcs use dynamic dispatch by default, while static funcs do not.

https://borgs.cybrilla.com/tils/global-vs-static-function-swift/

Static dispatch is faster than dynamic dispatch, as the compiler has the chance to inline stuff + other neat tricks.

https://medium.com/flawless-app-stories/static-vs-dynamic-dispatch-in-swift-a-decisive-choice-cece1e872d

So unless there is an explicit need for dynamic dispatch static func is preferable to class func. I don't see a benchmark tool but I imagine this is faster across the board.

RamblinWreck77 commented 4 years ago

The failure above is due to a test that tries to override one of the newly static functions. Is this test method absolutely required?

RamblinWreck77 commented 4 years ago

Closing this since it was merged in a different PR