From 2d06ea9184bfb262256068c9fa433bab42097328 Mon Sep 17 00:00:00 2001 From: Oneric Date: Mon, 29 Apr 2024 21:31:06 +0200 Subject: [PATCH] drawing: stop checking types for bezier curves Our parser should already guarantee types and counts are correct and VSFilter also only checks counts here. --- libass/ass_drawing.c | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/libass/ass_drawing.c b/libass/ass_drawing.c index ed940be40..e86b1c1df 100644 --- a/libass/ass_drawing.c +++ b/libass/ass_drawing.c @@ -30,19 +30,6 @@ #define DRAWING_INITIAL_POINTS 100 #define DRAWING_INITIAL_SEGMENTS 100 -/* - * \brief Check whether a number of items on the list is available - */ -static bool token_check_values(ASS_DrawingToken *token, int i, ASS_TokenType type) -{ - for (int j = 0; j < i; j++) { - if (!token || token->type != type) return false; - token = token->next; - } - - return true; -} - /* * \brief Free a list of tokens */ @@ -367,16 +354,13 @@ bool ass_drawing_parse(ASS_Outline *outline, ASS_Rect *cbox, break; } case TOKEN_CUBIC_BEZIER: - if (token_check_values(token, 3, TOKEN_CUBIC_BEZIER) && - token->prev) { - if (!drawing_add_curve(outline, cbox, token->prev, false, started)) - goto error; - token = token->next; - token = token->next; - token = token->next; - started = true; - } else - token = token->next; + assert_3_forward(token); + if (!drawing_add_curve(outline, cbox, token->prev, false, started)) + goto error; + token = token->next; + token = token->next; + token = token->next; + started = true; break; case TOKEN_B_SPLINE: assert_3_forward(token);