From 7c8793cbea1ea83109b7d9d6974d3f6991efcec8 Mon Sep 17 00:00:00 2001 From: Loic Blot Date: Sun, 15 Feb 2015 17:30:38 +0100 Subject: Performance Improvement: Use a cache which caches result for getFacePositions. This greatly reduce the number of std::list generated by caching the result, which is always constant for each radius selected. In the callgrind map, you will see original: * 3.3M calls to std::list for 9700 calls to getFacePositions In the modified version, you will see: * 3.3K calls to std::list for 6900 call to getFacePositions Callgrind map is here: #2321 it's a huge performance improvement to l_find_node_near --- src/clientiface.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'src/clientiface.cpp') diff --git a/src/clientiface.cpp b/src/clientiface.cpp index 9b952e36a..6180cf5da 100644 --- a/src/clientiface.cpp +++ b/src/clientiface.cpp @@ -59,7 +59,7 @@ void RemoteClient::ResendBlockIfOnWire(v3s16 p) } } -void RemoteClient::GetNextBlocks( +void RemoteClient::GetNextBlocks ( ServerEnvironment *env, EmergeManager * emerge, float dtime, @@ -182,18 +182,15 @@ void RemoteClient::GetNextBlocks( //bool queue_is_full = false; s16 d; - for(d = d_start; d <= d_max; d++) - { + for(d = d_start; d <= d_max; d++) { /* Get the border/face dot coordinates of a "d-radiused" box */ - std::list list; - getFacePositions(list, d); + std::vector list = FacePositionCache::getFacePositions(d); - std::list::iterator li; - for(li=list.begin(); li!=list.end(); ++li) - { + std::vector::iterator li; + for(li = list.begin(); li != list.end(); ++li) { v3s16 p = *li + center; /* -- cgit v1.2.3