• InFerNo@lemmy.ml
    link
    fedilink
    English
    arrow-up
    5
    ·
    24 days ago

    Put more curly brackets around your if (val) true statement for 4 more lines, put elses in there for more lines even.

    • Acters@lemmy.world
      link
      fedilink
      English
      arrow-up
      7
      ·
      edit-2
      24 days ago

      I should have created a local variable to store the result variable and return after the if statements. I just couldn’t help to make it look partially nice. My brain just doesn’t think at this high caliber of LOC optimizations.

      New optimized LOC version:

      internal static bool AreBooleansEqual(bool orig, bool val)
      {
          bool result;
          if(orig) 
          {
              if(val)
              {
                  result = false;
              }
              else
              {
                  result = true;
              }
          }
          else
          {
              if(val)
              {
                  result = true;
              }
              else
              {
                  result = false;
              }
          }
          return result;
      }
      

      My previous LOC: 12
      New LOC version: 27