summaryrefslogtreecommitdiff
path: root/src/nodedef.cpp
diff options
context:
space:
mode:
authorLoïc Blot <nerzhul@users.noreply.github.com>2017-07-26 20:12:48 +0200
committerGitHub <noreply@github.com>2017-07-26 20:12:48 +0200
commit3e50850260db13ec63ce4ca0e47e7fd7e30ce484 (patch)
treeeb07ce2418ad29152db2378dd9e75fb873cdafd4 /src/nodedef.cpp
parent9a17b65f26eea5b9d7176e7df205f72ed2ff6c0f (diff)
downloadminetest-3e50850260db13ec63ce4ca0e47e7fd7e30ce484.tar.gz
minetest-3e50850260db13ec63ce4ca0e47e7fd7e30ce484.tar.bz2
minetest-3e50850260db13ec63ce4ca0e47e7fd7e30ce484.zip
TileLayer: use shared_ptr for FrameSpec vector (#6171)
* TileLayer: use shared_ptr for vector framespec This reduce memory copy of TileLayer from (4 to 16) * FrameSpec where FrameSpec = (sizeof(int) + 3 * sizeof(ptr)) to int + sizeof(ptr) Callgrind difference Before: https://lut.im/RGkiJqQb8T/LeQIEXpAuRzfl7gd.png After: https://lut.im/bcqmwee1xu/cTwtptY5tRuS9lp0.png * Fix one push_back to use vector::emplace_back & optimize inclusions
Diffstat (limited to 'src/nodedef.cpp')
-rw-r--r--src/nodedef.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/nodedef.cpp b/src/nodedef.cpp
index 6bb2bf904..fc404f252 100644
--- a/src/nodedef.cpp
+++ b/src/nodedef.cpp
@@ -637,7 +637,10 @@ void ContentFeatures::fillTileAttribs(ITextureSource *tsrc, TileLayer *tile,
tile->material_flags &= ~MATERIAL_FLAG_ANIMATION;
} else {
std::ostringstream os(std::ios::binary);
- tile->frames.resize(frame_count);
+ if (!tile->frames) {
+ tile->frames = std::make_shared<std::vector<FrameSpec>>();
+ }
+ tile->frames->resize(frame_count);
for (int i = 0; i < frame_count; i++) {
@@ -652,7 +655,7 @@ void ContentFeatures::fillTileAttribs(ITextureSource *tsrc, TileLayer *tile,
if (tile->normal_texture)
frame.normal_texture = tsrc->getNormalTexture(os.str());
frame.flags_texture = tile->flags_texture;
- tile->frames[i] = frame;
+ (*tile->frames)[i] = frame;
}
}
}