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 1020065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T11:06:36+00:00 2026-05-16T11:06:36+00:00

Consider these to options if(successful) { if(condition) { //do something } if(condition) { //do

  • 0

Consider these to options

if(successful)
{
    if(condition)
    {
       //do something
    }
    if(condition)
    {
       //do something
    }
    ...
}

or

if(successful)&&(condition)
{
   //do something
}
if(successful)&&(condition)
{
   //do something
}
...

Imagine there 100 if statements.

Is there any difference in efficiency?

Thanks in advance.

  • 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-05-16T11:06:36+00:00Added an answer on May 16, 2026 at 11:06 am

    That all depends how costly it is to evaluate the successful expression.

    You should also note that the two versions are not semantically equivalent as the evaluation of the if-expression might have side-effects1.

    If you are actually facing performance issues then measure, don’t guess. Measuring will be the only way to see what the performance really is.

    1To explain a question from the comments, here is a simple example where you would get different behavior:

    The method CreateProcess has the side-effect of starting a new process and indicates the successful creation by returning true:

    bool CreateProcess(string filename, out handle) { ... } 
    
    if (CreateProcess("program.exe", out handle))
    {   
        if (someCondition)
        {
             handle.SomeMethod(...);
        }
        if (someOtherCondition)
        {
             handle.SomeOtherMethod(...);
        }
    }
    

    This is quite different from the following:

    if (CreateProcess("program.exe", out handle) && someCondition)
    {
        handle.SomeMethod(...);
    }
    if (CreateProcess("program.exe", out handle) && someOtherCondition)
    {
        handle.SomeOtherMethod(...);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 512k
  • Answers 512k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I'm not sure exactly what's happening, but then again, IE… May 16, 2026 at 5:33 pm
  • Editorial Team
    Editorial Team added an answer You cannot use CSS-hacks like the *-character in JavaScript. Try… May 16, 2026 at 5:33 pm
  • Editorial Team
    Editorial Team added an answer One alternative is Velocity, it's known as a webpage-templating framework… May 16, 2026 at 5:33 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have some doubts over how Enumerators work, and LINQ. Consider these two simple
I have an app that's about presenting fictional simplified cities. Please consider the following
Consider a PHP web application whose purpose is to accept user requests to start
Please consider the following HTML: <input type='text' id='name'/> <option id='option'> <select value='1'>hi</select> <select value='2'>bye</select>
I am using REST and OAuth to talk to a Rails app (from an
What is your best practical user-friendly user-interface design or principle? Please submit those practices
When I compiled my C++ code with GCC 4.3 for the first time, (after
Our usage case is a database responsible for accounts, sessions, licenses, etc. — it
I'm running a Django app using FastCGI and lighttpd. Can somebody explain me what
Does anyone have experience using a third-party unit testing framework for SAS such as

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.