Compiler device for optimizing program which manipulates a character
string includes append instruction detection unit, store code generation
unit, and append code generation unit. The append instruction detection
unit detects an append instruction which appends a character string to a
string variable for storing a character string, in the program. The store
code generation unit generates, a substitute for each of a plurality of
the append instructions detected by the append instruction detection
unit, a store code for storing data of an appendant character string to
be appended to the string variable by the append instruction into a
buffer. The append instructions append the character strings to the same
string variable. The append code generation unit generates append code
for appending a plurality of the appendant character strings to the
string variable, at a position executed before an instruction to refer to
the string variable in the program.