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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:50:39+00:00 2026-06-12T17:50:39+00:00

I am curious whether packing multiple and/or nested method calls within the same line

  • 0

I am curious whether packing multiple and/or nested method calls within the same line of code is better for performance and that is why some developers do it, at the cost of making their code less readable.

E.g.

//like
Set<String> jobParamKeySet = jobParams.keySet();
Iterator<String> jobParamItrtr = jobParamKeySet.iterator();

Could be also written as

//dislike    
Iterator<String> jobParamItrtr = jobParams.keySet().iterator();

Personally, I hate the latter because it does multiple evaluations in the same line and is hard for me to read the code. That is why I try to avoid by all means to have more than one evaluation per line of code. I also don’t know that jobParams.keySet() returns a Set and that bugs me.
Another example would be:

//dislike
Bar.processParameter(Foo.getParameter());

vs

//like
Parameter param = Foo.getParameter();
Bar.processParameter(param);

The former makes me noxious and dizzy as I like to consume simple and clean evaluations in every line of code and I just hate it when I see other people’s code written like that.

But are there any (performance) benefits to packing multiple method calls in the same line?

EDIT: Single liners are also more difficult to debug, thanks to @stemm for reminding

  • 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-12T17:50:40+00:00Added an answer on June 12, 2026 at 5:50 pm

    Micro optimization is killer. If the code references you are showing are either instance scope (or) method scope, I would go with second approach.

    Method scope variables will be eligible for GC as soon as method execution done, so even you declare another variable, it’s ok because scope is limited and the advantage you get will be readable and main-table code.

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

Sidebar

Related Questions

I'm looking at some code and I'm curious whether this is good practice. class
I am curious whether it is possible to determine the maximum size that an
I'm just curious whether there is a gui framework that alloys you to use
I don't have a code example, but I'm curious whether it's possible to write
I was curious whether anyone has any suggestions for performance testing libraries and frontends
Curious whether folks have setup 2 way transactional replication on the tables ASP.NET uses
When a popover shows, I'm curious whether it's possible to set the underlying settings
I was curious as to whether or not there exists a jQuery-style interface/library for
I am curious to know whether anyone out there have tried mixing node.js headless
I'm curious if it is possible to determine whether or not an Assembly has

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.