Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 673393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:35:27+00:00 2026-05-14T00:35:27+00:00

I heard that calling a handler (delegate, etc.) in Objective-C can be even faster

  • 0

I heard that calling a handler (delegate, etc.) in Objective-C can be even faster than calling a virtual function in C++. Is it really correct? If so, how can that be?

AFAIK, virtual functions are not that slow to call. At least, this is my understanding of what happens when a virtual function is called:

  1. Obtain the pointer to vtbl.
  2. De-reference the pointer and obtain the beginning of the array of function pointers.
  3. Offset (in pointer scale) the beginning of the array with the index of the method. Considering that the index is known at compile time, it’s as easy as adding a multiple of uintptr_t.
  4. Issue a call instruction.

Unfortunately, I don’t know Objective-C so it’s hard for me to compare performance. But at least, the mechanism of a virtual function call doesn’t look that slow, right? How can something other than static function call be faster?

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T00:35:28+00:00Added an answer on May 14, 2026 at 12:35 am

    This is all, of course, implementation-dependent. I don’t know if an Obj-C method call can be “faster” than a virtual function call, but it can certainly be in the ballpark– there’s discussion on the mechanism on SO here:

    Objective C message dispatch mechanism

    and Mike Ash has more here:

    http://www.mikeash.com/pyblog/friday-qa-2009-03-20-objective-c-messaging.html

    Bottom line is, selectors can be cached, and if the selector you’re calling is cached at runtime, the dispatch is on the order of operations of a virtual function call.

    Also:

    1. Standard disclaimer: The performance of this is essentially irrelevant for almost all code. It only matters in an incredible minority of cases. Can’t tell from your question, but basically this should not be a decision criterion in figuring out whether to implement a bunch of code in pure Obj-C or C++.
    2. You can always watch the behavior (and count the ops 🙂 ) explicitly by stepping through the asm in Xcode– if you do, report back!
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I heard that Google can track all the static pages in a website and
I heard that SQL is faster if table relationships are defined. Is this true?
I heard that C# is a rapid application development (RAD) language. Even after reading
In my wxPython app I have an EVT_IDLE handler that calls some function that
I am calling a JSP page through jQuery that handles downloading files. $(#download).click(function(e){ $.get(download.jsp,
I heard that it's possible to identify the brand of a device (or at
I heard that having @foreach inside of a view is a no-no. Meaning, the
I heard that you need to create images for both retina and non-retina. And
I heard that JNBridge will translate C# code to native Java code.( I haven't
I heard that in C, if I do char *s = hello world. the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.