[haiku-commits] Re: BRANCH midar-github.master - in src: kits/app kits/support apps/soundrecorder kits/locale

  • From: Stephan AÃmus <superstippi@xxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Tue, 20 Nov 2012 09:57:21 +0100

Sorry about replying to myself...

Am 20.11.2012 09:49, schrieb Stephan AÃmus:
Thinking about it, this could even be wrapped in a templated utility
class to minimize the typing overhead. Then one would type something like:

BStackOrHeapArray<BPoint, 64> pointArray(pointCount);
if (!pointArray.IsValid())
     return B_NO_MEMORY;

BPoint* pointList = pointArray.Array();
// ...

If this looks almost identical to using std::vector to anyone, there is one important difference: Doing real memory allocation versus allocating stack space can mean a huge performance difference. It can even mean the thread is preempted. So optimizing for small array sizes to be allocated on the stack is worthwhile in certain code paths. Certainly in drawing code paths.

Best regards,
-Stephan



Other related posts: