SFML community forums

General => Feature requests => Topic started by: FRex on September 16, 2012, 05:55:35 pm

Title: More controll over sf::VertexArray's vector
Post by: FRex on September 16, 2012, 05:55:35 pm
If we know how many vertices we will load we could reserve() space instead of relying on appends(push_backs) that will :
1. reallocate few times
2. possibly reserve more memory than they need
How bad these two will be depends on implementation of the vector.
The un-solution is using resize but it still feels like there are unnecessary restrictions.

Possible changes I think of:
- reserve(vector's reserve) and/or trim(Scott Meyer's ranged swap on the underlying vector) methods
- method to return non-const pointer/reference to underlying vector since it seems nothing in the vertex array code will break no matter what is done to the vector(except deletion, but really, delete &something; can be done on anything and there are more dangerous things in sfml already).
Title: Re: More controll over sf::VertexArray's vector
Post by: Laurent on September 16, 2012, 07:27:25 pm
sf::VertexArray is just a simple wrapper for people who could be scared to use a std::vector. But if you want more power, use it directly.
Title: Re: More controll over sf::VertexArray's vector
Post by: FRex on September 16, 2012, 07:38:56 pm
I am :P but I wanted to point this out since in my case the numbers were quite scary.