Bug 852011 - Reserve 5 elements in MediaStream::mBlocked in order to avoid excessive cost when dealing with removals from it; r=roc

--HG--
extra : rebase_source : 480c95b4110dcd8355d08eacbbbe91f963d73239
This commit is contained in:
Ehsan Akhgari 2013-03-17 23:27:14 -04:00
parent 95d895501d
commit b953c5fc81
2 changed files with 9 additions and 6 deletions

View File

@ -457,7 +457,7 @@ protected:
VideoFrame mLastPlayedVideoFrame;
// The number of times this stream has been explicitly blocked by the control
// API, minus the number of times it has been explicitly unblocked.
TimeVarying<GraphTime,uint32_t> mExplicitBlockerCount;
TimeVarying<GraphTime,uint32_t,0> mExplicitBlockerCount;
nsTArray<nsRefPtr<MediaStreamListener> > mListeners;
nsTArray<MainThreadMediaStreamListener*> mMainThreadListeners;
@ -467,9 +467,9 @@ protected:
// not been blocked before mCurrentTime (its mBufferStartTime is increased
// as necessary to account for that time instead) --- this avoids us having to
// record the entire history of the stream's blocking-ness in mBlocked.
TimeVarying<GraphTime,bool> mBlocked;
TimeVarying<GraphTime,bool,5> mBlocked;
// Maps graph time to the graph update that affected this stream at that time
TimeVarying<GraphTime,int64_t> mGraphUpdateIndices;
TimeVarying<GraphTime,int64_t,0> mGraphUpdateIndices;
// MediaInputPorts to which this is connected
nsTArray<MediaInputPort*> mConsumers;

View File

@ -32,7 +32,10 @@ protected:
* a mathematical function of time.
* Time is the type of time values, T is the value that changes over time.
* There are a finite set of "change times"; at each change time, the function
* instantly changes to a new value.
* instantly changes to a new value. ReservedChanges should be set to the
* expected number of change events that the object is likely to contain.
* This value should be 0 for all consumers unless you know that a higher value
* would be a benefit.
* There is also a "current time" which must always advance (not go backward).
* The function is constant for all times less than the current time.
* When the current time is advanced, the value of the function at the new
@ -42,7 +45,7 @@ protected:
* and an array of "change times" (greater than the current time) and the
* new value for each change time. This is a simple but dumb implementation.
*/
template <typename Time, typename T>
template <typename Time, typename T, uint32_t ReservedChanges>
class TimeVarying : public TimeVaryingBase {
public:
TimeVarying(const T& aInitial) : mCurrent(aInitial) {}
@ -214,7 +217,7 @@ private:
Time mTime;
T mValue;
};
nsTArray<Entry> mChanges;
nsAutoTArray<Entry, ReservedChanges> mChanges;
T mCurrent;
};