summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxhe <xw897002528@gmail.com>2018-02-18 11:52:07 +0800
committerxhe <xw897002528@gmail.com>2018-02-18 11:52:07 +0800
commit69ba3c3e333e2f1fed310052074e73e965ada1bc (patch)
tree01249c6f1d513dd8d15b23200e592d8e326dfc5c
parente22565a69ec395f4b3e531e207b0f0b80d5cacd6 (diff)
downloadgettext-tiny-69ba3c3e333e2f1fed310052074e73e965ada1bc.tar.gz
msgmerge: make convbuf a local var of function
As discussed with rofl0r, stack allocation is super fast. We could just make convbuf a local variable, for not to confuse readers. This buffer is only used in this function, and we dont need to worry about the performance of repeated allocation.
-rw-r--r--src/msgmerge.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/msgmerge.c b/src/msgmerge.c
index 2a5e041..85dc3b4 100644
--- a/src/msgmerge.c
+++ b/src/msgmerge.c
@@ -37,35 +37,35 @@ struct fiLes {
FILE *pot;
FILE *compend;
int plural_count;
- char convbuf[16384];
enum po_entry prev_type;
};
/* currently we only output input strings as output strings
* i.e. there is no translation lookup at all */
int process_line_callback(struct po_info* info, void* user) {
+ char convbuf[16384];
struct fiLes* file = (struct fiLes*) user;
// escape what is unescaped automatically by lib
- escape(info->text, file->convbuf, sizeof(file->convbuf));
+ escape(info->text, convbuf, sizeof(convbuf));
switch (info->type) {
case pe_msgid:
file->plural_count = 1;
- fprintf(file->out, "\nmsgid \"%s\"\n", file->convbuf);
+ fprintf(file->out, "\nmsgid \"%s\"\n", convbuf);
file->prev_type = info->type;
break;
case pe_ctxt:
- fprintf(file->out, "msgctxt \"%s\"\n", file->convbuf);
+ fprintf(file->out, "msgctxt \"%s\"\n", convbuf);
break;
case pe_plural:
- fprintf(file->out, "msgid_plural \"%s\"\n", file->convbuf);
+ fprintf(file->out, "msgid_plural \"%s\"\n", convbuf);
file->prev_type = info->type;
break;
case pe_msgstr:
if (file->prev_type == pe_plural) {
- fprintf(file->out, "msgstr[%d] \"%s\"\n", file->plural_count++, file->convbuf);
+ fprintf(file->out, "msgstr[%d] \"%s\"\n", file->plural_count++, convbuf);
} else {
- fprintf(file->out, "msgstr \"%s\"\n", file->convbuf);
+ fprintf(file->out, "msgstr \"%s\"\n", convbuf);
}
break;
}