void ContextualGlyphInsertionProcessor2::doInsertion(LEGlyphStorage &glyphStorage, le_int32 atGlyph, le_uint16 &index, le_uint16 count, le_bool /* isKashidaLike */, le_bool isBefore, LEErrorCode &success)
{
    if (!count)
        return;

    LEGlyphID *insertGlyphs = glyphStorage.insertGlyphs(atGlyph, count + 1, success);

    if (LE_FAILURE(success))
        return;

    for (le_uint32 glyph = 0; glyph < count + 1; glyph++)
        insertGlyphs[glyph] = 0; // undef

    // Note: Kashida vs Split Vowel seems to only affect selection and highlighting.
    // We note the flag, but do not layout different.
    // https://developer.apple.com/fonts/TTRefMan/RM06/Chap6mort.html

    le_int16 targetIndex = 0;

    if (isBefore) {
        insertGlyphs[count] = glyphStorage[atGlyph];
    } else {
        insertGlyphs[targetIndex++] = glyphStorage[atGlyph];
    }

    while(count-- && LE_SUCCESS(success)) {
        le_uint16 insertGlyph;

        if (insertionAction.getObject(index++, insertGlyph, success))
            insertGlyphs[targetIndex++] = SWAPW(insertGlyph);
    }
}