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

  • SEARCH
  • Home
  • 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 8520595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:34:44+00:00 2026-06-11T06:34:44+00:00

What happens if the switch has more than 5000 case . What are the

  • 0

What happens if the switch has more than 5000 case. What are the drawbacks and how we can replace it with something faster?

Note: I am not expecting to use array to store cases as it’s the same.

  • 1 1 Answer
  • 0 Views
  • 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-06-11T06:34:45+00:00Added an answer on June 11, 2026 at 6:34 am

    There’s no specific reason to think you’d want anything other than a switch/case statement (and indeed I’d actively expect it to be unhelpful). The compiler should create efficient dispatching code, which might involve some combination of static [sparse] table(s) and direct indexing, binary branching etc.; it’s got insights into the static values of the cases and should do an excellent job (retuning it on the fly each time you change the cases, whereas new values that don’t fit well with a hand-crafted approach – such as wildly differing values when you’d had a pretty packed array lookup – could require reworking of code or silently cause memory bloat or a performance drop).

    People really cared about this kind of thing back when C was trying to win over hard-core assembly programmers… the compilers were held accountable for generating good code. Put another way – if it’s not (measurably) broken, don’t fix it.

    More generally, it’s great to be curious about this kind of thing and get people’s ideas on alternatives and their performance implications, but if you really care and the performance difference could make a useful difference to your program (especially if profiling suggests it) then always benchmark with your program doing real work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I feel this is a more logic problem than anything. A database has pictures
In my application I've created a wizard. It seems like I can not switch
Is their any cases in C++ Like these case WM_COMMAND: switch(LOWORD(wParam)) That happen when
Xcode has a feature which allows you to quickly switch between a {.m,.c,.cpp} file
Possible Duplicate: How can I get device ID for Admob My activity has a
I have recently learned that you can use a neat switch statement with fallthrough
What happens when a thread is put to sleep by other thread, possible by
What happens in the following code? Does the synchronization work? This is an interview
What happens in the following example? struct B { }; struct D1 : B
What happens when an application pool is recycled in IIS 7? Does IIS abruptly

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.