From: Rafael Espindola Date: Thu, 9 Apr 2015 17:16:25 +0000 (+0000) Subject: Use a raw_svector_ostream instead of a raw_string_ostream. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=440f0b28a8061d86678d35fe0a45936b5eaf91d3;p=oota-llvm.git Use a raw_svector_ostream instead of a raw_string_ostream. It saves a bit of copying. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234507 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/TargetMachineC.cpp b/lib/Target/TargetMachineC.cpp index 236cb1bed96..aaa66d3bf61 100644 --- a/lib/Target/TargetMachineC.cpp +++ b/lib/Target/TargetMachineC.cpp @@ -183,7 +183,9 @@ void LLVMSetTargetMachineAsmVerbosity(LLVMTargetMachineRef T, } static LLVMBool LLVMTargetMachineEmit(LLVMTargetMachineRef T, LLVMModuleRef M, - formatted_raw_ostream &OS, LLVMCodeGenFileType codegen, char **ErrorMessage) { + formatted_raw_ostream &OS, + LLVMCodeGenFileType codegen, + char **ErrorMessage) { TargetMachine* TM = unwrap(T); Module* Mod = unwrap(M); @@ -238,15 +240,15 @@ LLVMBool LLVMTargetMachineEmitToFile(LLVMTargetMachineRef T, LLVMModuleRef M, LLVMBool LLVMTargetMachineEmitToMemoryBuffer(LLVMTargetMachineRef T, LLVMModuleRef M, LLVMCodeGenFileType codegen, char** ErrorMessage, LLVMMemoryBufferRef *OutMemBuf) { - std::string CodeString; - raw_string_ostream OStream(CodeString); + SmallString<0> CodeString; + raw_svector_ostream OStream(CodeString); formatted_raw_ostream Out(OStream); bool Result = LLVMTargetMachineEmit(T, M, Out, codegen, ErrorMessage); OStream.flush(); - std::string &Data = OStream.str(); - *OutMemBuf = LLVMCreateMemoryBufferWithMemoryRangeCopy(Data.c_str(), - Data.length(), ""); + StringRef Data = OStream.str(); + *OutMemBuf = + LLVMCreateMemoryBufferWithMemoryRangeCopy(Data.data(), Data.size(), ""); return Result; }