Skip to content

Commit

Permalink
avoid using vsnprintf when possible for SStream_concat() to improve p…
Browse files Browse the repository at this point in the history
…erformance. based on the idea of Dang Hoang Vu.
  • Loading branch information
aquynh committed Jun 4, 2014
1 parent 59caae0 commit b76233c
Show file tree
Hide file tree
Showing 4 changed files with 188 additions and 177 deletions.
9 changes: 9 additions & 0 deletions SStream.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <stdint.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>

#include "SStream.h"
#include "cs_priv.h"
Expand All @@ -14,6 +15,14 @@ void SStream_Init(SStream *ss)
ss->buffer[0] = '\0';
}

void SStream_concat0(SStream *ss, char *s)
{
#ifndef CAPSTONE_DIET
strcpy(ss->buffer + ss->index, s);
ss->index += strlen(s);
#endif
}

void SStream_concat(SStream *ss, const char *fmt, ...)
{
#ifndef CAPSTONE_DIET
Expand Down
2 changes: 2 additions & 0 deletions SStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ void SStream_Init(SStream *ss);

void SStream_concat(SStream *ss, const char *fmt, ...);

void SStream_concat0(SStream *ss, char *s);

#endif
Loading

0 comments on commit b76233c

Please sign in to comment.