Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: More controll over sf::VertexArray's vector  (Read 1327 times)

0 Members and 1 Guest are viewing this topic.

FRex

  • Hero Member
  • *****
  • Posts: 1843
    • View Profile
    • My GitHub Page
    • Email
More controll over sf::VertexArray's vector
« 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).
ZipSavings, script to count rar/7z/zip savings: https://goo.gl/vvBj5M
LuaConsole: https://goo.gl/X4kRUk
FoxRaycaster: https://goo.gl/27nVS8
Small Games - Heart, Routing and Snek: https://goo.gl/15ZGWE https://goo.gl/k5gwWD https://goo.gl/4nKPnT
Botes - a notes app in Pascal: https://goo.gl/bzTqsi

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32466
    • View Profile
    • SFML's website
    • Email
Re: More controll over sf::VertexArray's vector
« Reply #1 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.
Laurent Gomila - SFML developer

FRex

  • Hero Member
  • *****
  • Posts: 1843
    • View Profile
    • My GitHub Page
    • Email
Re: More controll over sf::VertexArray's vector
« Reply #2 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.
ZipSavings, script to count rar/7z/zip savings: https://goo.gl/vvBj5M
LuaConsole: https://goo.gl/X4kRUk
FoxRaycaster: https://goo.gl/27nVS8
Small Games - Heart, Routing and Snek: https://goo.gl/15ZGWE https://goo.gl/k5gwWD https://goo.gl/4nKPnT
Botes - a notes app in Pascal: https://goo.gl/bzTqsi