[vlc-commits] subtitle-demux: speedup SSA parser
Hannes Domani
git at videolan.org
Thu Sep 11 06:11:35 CEST 2014
vlc | branch: master | Hannes Domani <ssbssa at yahoo.de> | Wed Sep 10 13:12:33 2014 +0200| [6cccd64dacf431e1c33877e131b09ff906c85972] | committer: Tristan Matthews
subtitle-demux: speedup SSA parser
Signed-off-by: Tristan Matthews <le.businessman at gmail.com>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6cccd64dacf431e1c33877e131b09ff906c85972
---
modules/demux/subtitle.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/modules/demux/subtitle.c b/modules/demux/subtitle.c
index ad9b38e..1b22c7d 100644
--- a/modules/demux/subtitle.c
+++ b/modules/demux/subtitle.c
@@ -1083,6 +1083,7 @@ static int ParseSSA( demux_t *p_demux, subtitle_t *p_subtitle,
{
demux_sys_t *p_sys = p_demux->p_sys;
text_t *txt = &p_sys->txt;
+ size_t header_len = 0;
for( ;; )
{
@@ -1155,12 +1156,12 @@ static int ParseSSA( demux_t *p_demux, subtitle_t *p_subtitle,
free( psz_text );
/* All the other stuff we add to the header field */
- char *psz_header;
- if( asprintf( &psz_header, "%s%s\n",
- p_sys->psz_header ? p_sys->psz_header : "", s ) == -1 )
+ size_t s_len = strlen( s );
+ p_sys->psz_header = realloc_or_free( p_sys->psz_header, header_len + s_len + 2 );
+ if( !p_sys->psz_header )
return VLC_ENOMEM;
- free( p_sys->psz_header );
- p_sys->psz_header = psz_header;
+ snprintf( p_sys->psz_header + header_len, s_len + 2, "%s\n", s );
+ header_len += s_len + 1;
}
}
More information about the vlc-commits
mailing list