2 ms·
Apple's implementation actually adds a (potentially hard-to-predict) branch to every single Objective-C message send. They're extremely careful about the perfo
by mikeash 11y ago
Apple's implementation actually adds a (potentially hard-to-predict) branch to every single Objective-C message send.
They're extremely careful about the performance of objc_msgSend, because it's so significant to the overall performance of apps. The running time for a hot path message send is down to single digit CPU cycles. Any addition to that shows up pretty loudly. I'm sure they checked to make sure the check doesn't add too much overhead in real-world use, and that the wins are worth it.