Skip unneeded reallocs in SkTDArray::shrinkToFit()
Change-Id: I885eb1769ffa639026929dc7aa68312e0dbf91b8 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/250037 Reviewed-by: Mike Klein <mtklein@google.com> Commit-Queue: Florin Malita <fmalita@chromium.org>
This commit is contained in:
parent
cc13acbffe
commit
3d5ccfd9d7
@ -319,8 +319,11 @@ public:
|
||||
#endif
|
||||
|
||||
void shrinkToFit() {
|
||||
fReserve = fCount;
|
||||
fArray = (T*)sk_realloc_throw(fArray, fReserve * sizeof(T));
|
||||
if (fReserve != fCount) {
|
||||
SkASSERT(fReserve > fCount);
|
||||
fReserve = fCount;
|
||||
fArray = (T*)sk_realloc_throw(fArray, fReserve * sizeof(T));
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
|
Loading…
Reference in New Issue
Block a user