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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:58:55+00:00 2026-05-26T04:58:55+00:00

I am aware that this is an easy problem but I don’t know how

  • 0

I am aware that this is an easy problem but I don’t know how to do properly what I have in mind. I am using SFML but you don’t need to understand how it works.
Here is my simple code snippet that generate tiles and assign them to a 2D-vector of tiles:
http://www.pastie.org/2665489

During the construction of the TilePlane object, each operation (tilesMap[i]).push_back(tile) takes far too long and I feel that I am copying data instead of using a more elegant method. So in this case, what is the good method to solve this problem?

  • 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-26T04:58:55+00:00Added an answer on May 26, 2026 at 4:58 am

    You have a lot of performance issues in your code. If the bottleneck indeed comes from push_back, you should take Masoud’s suggestion and push pointers onto the array and not values.

    Another suggestion is that you declare your functions and constructors to use references – for example:

    Tile::Tile(const Tileset& tileset, int tileId, int posX, int posY)
    

    instead of

    Tile::Tile(Tileset tileset, int tileId, int posX, int posY)
    

    Passing the parameter by value will force a copy to be created, which can be expensive. Passing by const reference guarantees the object is not copied or modified.

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

Sidebar

Related Questions

I aware that this will be a less programming question, but still... How can
I have created a basic WCF service in IIS. I am aware that this
I'm aware that MD5 has had some collisions but this is more of a
Has anyone already tried this, anything particulair that I need to be aware of?
First off, I'm aware that there are many questions related to this, but none
I'm aware that you can do this: public ActionResult DoSomething([Bind(Exclude = CreationDate)] Item item)
In the answer to this question ovanes states: Please be aware that boost::lexical_cast is
In this question , I was made aware of glob()'s GLOB_BRACE option that allows
So, here's the problem (it's probably an easy one :P) This is my table
This is a biggie. I have a well-structured yet monolithic code base that 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.