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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T05:23:16+00:00 2026-06-02T05:23:16+00:00

What is the most performant way to build strings from strings, integers and floats?

  • 0

What is the most performant way to build strings from strings, integers and floats? currently I’m doing this and it uses a lot of cpu time.

String frame = this.frameTime + ":" +
    this.player.vertices[0].x + "," +
    this.player.vertices[0].y + "," +
    this.player.activeAnimId + "," +
    (int)this.player.virtualSpeed + "," +
    this.map.getCurrentTime() + 
    (this.player.frameSound == -1 ? "" : "," + this.player.frameSound) +
    (this.player.frameDecal.equals("") ? "" : "," + this.player.frameDecal) +
    ";";

Is there a way to do this faster?

  • 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-02T05:23:17+00:00Added an answer on June 2, 2026 at 5:23 am

    That should already be fast – it’ll use StringBuilder internally for concatenation. Arguably using StringBuilder explicitly could eliminate the concatenation of empty strings, but it’s not likely to make a big difference.

    How often are you doing this, anyway? It must be pretty often, for it to be a bottleneck… do you really need to do it that often?

    EDIT: For those who are saying “Use StringBuilder, it’ll be faster” – consider this code:

    public class Test
    {
        public static void main(String[] args)
        {
            int x = 10;
            int y = 20;
            int z = 30;
            String foo = x + "," + y + "," + z + ";";
            System.out.println(foo);
        }
    }
    

    Compile that, then use javap -c to see what the compiler generates…

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

Sidebar

Related Questions

I thought that this is the most efficient way to concatinate strings new StringBuilder(s1.length()
I am looking for the most performant way to arrange usage of the datacache
Most of this info isn't needed to answer my question, I am including it,
Most of the time, when designing an desktop application, I love to make the
I plan to build a photo-sharing site like Flickr/Picasa for photographers, with features most
Newb question: jQuery('.foo')[0] does the job most of the time. jQuery('.foo:first')[0] is slightly more
I would like to build an application that uses Genetic Programming to figure out
Most of the longest (most time-consuming) logic I've encountered basically involves two things: sending
I am away from my development workstation so I thought I'd ask this in
I'm using Knockout.js to build most of my UI and I'm looking for a

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.