From e611f2c571e66fd28dc7296a179c63df6f120ea5 Mon Sep 17 00:00:00 2001 From: cutealien Date: Thu, 6 May 2021 15:01:05 +0000 Subject: [PATCH] Speedup for COBJMeshWriter Avoiding some memory allocations. git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6213 dfc29bdd-3216-0410-991c-e03cc46cb475 --- changes.txt | 1 + source/Irrlicht/COBJMeshWriter.cpp | 27 +++++++++------------------ 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/changes.txt b/changes.txt index 12a0a857..781b51db 100644 --- a/changes.txt +++ b/changes.txt @@ -1,5 +1,6 @@ -------------------------- Changes in 1.9 (not yet released) +- Speedup for COBJMeshWriter - Add blinkMode parameter to IGUIEnvironment::addModalScreen, so blinking can be suppressed - Speedup: Avoid string copy in CXMLReaderImpl::getAttributeByName - Fix bug in rect::clipAgainst that had caused rects completely outside to the left-top of the rect to be clipped against ending up with both corners outside. diff --git a/source/Irrlicht/COBJMeshWriter.cpp b/source/Irrlicht/COBJMeshWriter.cpp index c784caf1..372b9c2f 100644 --- a/source/Irrlicht/COBJMeshWriter.cpp +++ b/source/Irrlicht/COBJMeshWriter.cpp @@ -244,34 +244,25 @@ bool COBJMeshWriter::writeMesh(io::IWriteFile* file, scene::IMesh* mesh, s32 fla void COBJMeshWriter::getVectorAsStringLine(const core::vector3df& v, core::stringc& s) const { - s = core::stringc(-v.X); - s += " "; - s += core::stringc(v.Y); - s += " "; - s += core::stringc(v.Z); - s += "\n"; + c8 tmpbuf[255]; + snprintf_irr(tmpbuf, 255, "%f %f %f\n", -v.X, v.Y, v.Z); + s = tmpbuf; } void COBJMeshWriter::getVectorAsStringLine(const core::vector2df& v, core::stringc& s) const { - s = core::stringc(v.X); - s += " "; - s += core::stringc(1-v.Y); - s += "\n"; + c8 tmpbuf[255]; + snprintf_irr(tmpbuf, 255, "%f %f\n", v.X, 1.f-v.Y); + s = tmpbuf; } void COBJMeshWriter::getColorAsStringLine(const video::SColor& color, const c8* const prefix, core::stringc& s) const { - s = prefix; - s += " "; - s += core::stringc((double)(color.getRed()/255.f)); - s += " "; - s += core::stringc((double)(color.getGreen()/255.f)); - s += " "; - s += core::stringc((double)(color.getBlue()/255.f)); - s += "\n"; + c8 tmpbuf[255]; + snprintf_irr(tmpbuf, 255, "%s %f %f %f\n", prefix, (float)(color.getRed()/255.f), (float)(color.getGreen()/255.f), (float)(color.getBlue()/255.f)); + s = tmpbuf; }