bug 1035323 - remove redundant null-checks in the DetailedGlyphStore code. r=jdaggett

This commit is contained in:
Jonathan Kew 2014-07-08 14:56:41 +01:00
Родитель ed7ebf4bf9
Коммит c6ad2091d7
2 изменённых файлов: 10 добавлений и 52 удалений

Просмотреть файл

@ -6493,13 +6493,7 @@ gfxShapedText::AllocateDetailedGlyphs(uint32_t aIndex, uint32_t aCount)
mDetailedGlyphs = new DetailedGlyphStore();
}
DetailedGlyph *details = mDetailedGlyphs->Allocate(aIndex, aCount);
if (!details) {
GetCharacterGlyphs()[aIndex].SetMissing(0);
return nullptr;
}
return details;
return mDetailedGlyphs->Allocate(aIndex, aCount);
}
void
@ -6513,9 +6507,6 @@ gfxShapedText::SetGlyphs(uint32_t aIndex, CompressedGlyph aGlyph,
uint32_t glyphCount = aGlyph.GetGlyphCount();
if (glyphCount > 0) {
DetailedGlyph *details = AllocateDetailedGlyphs(aIndex, glyphCount);
if (!details) {
return;
}
memcpy(details, aGlyphs, sizeof(DetailedGlyph)*glyphCount);
}
GetCharacterGlyphs()[aIndex] = aGlyph;
@ -6544,9 +6535,6 @@ gfxShapedText::SetMissingGlyph(uint32_t aIndex, uint32_t aChar, gfxFont *aFont)
}
DetailedGlyph *details = AllocateDetailedGlyphs(aIndex, 1);
if (!details) {
return;
}
details->mGlyphID = aChar;
if (IsDefaultIgnorable(aChar)) {
@ -6569,14 +6557,12 @@ gfxShapedText::FilterIfIgnorable(uint32_t aIndex, uint32_t aCh)
{
if (IsDefaultIgnorable(aCh)) {
DetailedGlyph *details = AllocateDetailedGlyphs(aIndex, 1);
if (details) {
details->mGlyphID = aCh;
details->mAdvance = 0;
details->mXOffset = 0;
details->mYOffset = 0;
GetCharacterGlyphs()[aIndex].SetMissing(1);
return true;
}
details->mGlyphID = aCh;
details->mAdvance = 0;
details->mXOffset = 0;
details->mYOffset = 0;
GetCharacterGlyphs()[aIndex].SetMissing(1);
return true;
}
return false;
}
@ -7656,24 +7642,6 @@ gfxTextRun::CountMissingGlyphs()
return count;
}
gfxTextRun::DetailedGlyph *
gfxTextRun::AllocateDetailedGlyphs(uint32_t aIndex, uint32_t aCount)
{
NS_ASSERTION(aIndex < GetLength(), "Index out of range");
if (!mDetailedGlyphs) {
mDetailedGlyphs = new DetailedGlyphStore();
}
DetailedGlyph *details = mDetailedGlyphs->Allocate(aIndex, aCount);
if (!details) {
mCharacterGlyphs[aIndex].SetMissing(0);
return nullptr;
}
return details;
}
void
gfxTextRun::CopyGlyphDataFrom(gfxShapedWord *aShapedWord, uint32_t aOffset)
{

Просмотреть файл

@ -2625,23 +2625,16 @@ protected:
DetailedGlyph* Allocate(uint32_t aOffset, uint32_t aCount) {
uint32_t detailIndex = mDetails.Length();
DetailedGlyph *details = mDetails.AppendElements(aCount);
if (!details) {
return nullptr;
}
// We normally set up glyph records sequentially, so the common case
// here is to append new records to the mOffsetToIndex array;
// test for that before falling back to the InsertElementSorted
// method.
if (mOffsetToIndex.Length() == 0 ||
aOffset > mOffsetToIndex[mOffsetToIndex.Length() - 1].mOffset) {
if (!mOffsetToIndex.AppendElement(DGRec(aOffset, detailIndex))) {
return nullptr;
}
mOffsetToIndex.AppendElement(DGRec(aOffset, detailIndex));
} else {
if (!mOffsetToIndex.InsertElementSorted(DGRec(aOffset, detailIndex),
CompareRecordOffsets())) {
return nullptr;
}
mOffsetToIndex.InsertElementSorted(DGRec(aOffset, detailIndex),
CompareRecordOffsets());
}
return details;
}
@ -3457,9 +3450,6 @@ protected:
private:
// **** general helpers ****
// Allocate aCount DetailedGlyphs for the given index
DetailedGlyph *AllocateDetailedGlyphs(uint32_t aCharIndex, uint32_t aCount);
// Get the total advance for a range of glyphs.
int32_t GetAdvanceForGlyphs(uint32_t aStart, uint32_t aEnd);