[vlc-commits] subtitle-demux: speedup SSA parser
Hannes Domani
git at videolan.org
Thu Sep 11 06:16:39 CEST 2014
vlc/vlc-2.2 | branch: master | Hannes Domani <ssbssa at yahoo.de> | Wed Sep 10 13:12:33 2014 +0200| [642b319a89d42da815df0ef689a31a09f975f05a] | committer: Tristan Matthews
subtitle-demux: speedup SSA parser
Signed-off-by: Tristan Matthews <le.businessman at gmail.com>
(cherry picked from commit 6cccd64dacf431e1c33877e131b09ff906c85972)
> http://git.videolan.org/gitweb.cgi/vlc/vlc-2.2.git/?a=commit;h=642b319a89d42da815df0ef689a31a09f975f05a
---
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 b20389c..c2a7642 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