Skip to content

Fix #514: 50x performance drop when calling overloaded function with mismatched type#688

Open
leftibot wants to merge 1 commit into
ChaiScript:developfrom
leftibot:fix/issue-514-50x-performance-drop-when-calling-overlo
Open

Fix #514: 50x performance drop when calling overloaded function with mismatched type#688
leftibot wants to merge 1 commit into
ChaiScript:developfrom
leftibot:fix/issue-514-50x-performance-drop-when-calling-overlo

Conversation

@leftibot
Copy link
Copy Markdown
Contributor

Automated fix by @leftibot.

What changed

Fix #514: Avoid exception-based control flow for arithmetic type dispatch
During overloaded function dispatch, when a function's parameter mismatches
are all arithmetic-to-arithmetic (e.g., int where float is expected), the
dispatcher now performs inline Boxed_Number conversion before calling the
function. Previously, the function was called with mismatched types, threw
bad_boxed_cast, and fell through to dispatch_with_conversions — a slow path
on platforms like MSVC where exceptions are expensive under the debugger.
Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com

Files

 include/chaiscript/dispatchkit/proxy_functions.hpp | 73 ++++++++++++++--------
 unittests/compiled_tests.cpp                       | 47 ++++++++++++++
 2 files changed, 94 insertions(+), 26 deletions(-)

Closes #514

Triggered by @lefticus.

… type dispatch

During overloaded function dispatch, when a function's parameter mismatches
are all arithmetic-to-arithmetic (e.g., int where float is expected), the
dispatcher now performs inline Boxed_Number conversion before calling the
function. Previously, the function was called with mismatched types, threw
bad_boxed_cast, and fell through to dispatch_with_conversions — a slow path
on platforms like MSVC where exceptions are expensive under the debugger.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

50x performance drop when calling overloaded function with mismatched type

1 participant