Skip to content

Commit 3c91ad8

Browse files
committedFeb 17, 2015
Replace std::list by std::vector into timerUpdate calls
1 parent 24315db commit 3c91ad8

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed
 

Diff for: ‎src/client.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ void Client::step(float dtime)
434434
const float map_timer_and_unload_dtime = 5.25;
435435
if(m_map_timer_and_unload_interval.step(dtime, map_timer_and_unload_dtime)) {
436436
ScopeProfiler sp(g_profiler, "Client: map timer and unload");
437-
std::list<v3s16> deleted_blocks;
437+
std::vector<v3s16> deleted_blocks;
438438
m_env.getMap().timerUpdate(map_timer_and_unload_dtime,
439439
g_settings->getFloat("client_unload_unused_data_timeout"),
440440
&deleted_blocks);
@@ -444,8 +444,8 @@ void Client::step(float dtime)
444444
NOTE: This loop is intentionally iterated the way it is.
445445
*/
446446

447-
std::list<v3s16>::iterator i = deleted_blocks.begin();
448-
std::list<v3s16> sendlist;
447+
std::vector<v3s16>::iterator i = deleted_blocks.begin();
448+
std::vector<v3s16> sendlist;
449449
for(;;) {
450450
if(sendlist.size() == 255 || i == deleted_blocks.end()) {
451451
if(sendlist.empty())
@@ -462,7 +462,7 @@ void Client::step(float dtime)
462462
*pkt << (u8) sendlist.size();
463463

464464
u32 k = 0;
465-
for(std::list<v3s16>::iterator
465+
for(std::vector<v3s16>::iterator
466466
j = sendlist.begin();
467467
j != sendlist.end(); ++j) {
468468
*pkt << *j;

Diff for: ‎src/map.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -1421,7 +1421,7 @@ bool Map::getDayNightDiff(v3s16 blockpos)
14211421
Updates usage timers
14221422
*/
14231423
void Map::timerUpdate(float dtime, float unload_timeout,
1424-
std::list<v3s16> *unloaded_blocks)
1424+
std::vector<v3s16> *unloaded_blocks)
14251425
{
14261426
bool save_before_unloading = (mapType() == MAPTYPE_SERVER);
14271427

@@ -1435,8 +1435,7 @@ void Map::timerUpdate(float dtime, float unload_timeout,
14351435

14361436
beginSave();
14371437
for(std::map<v2s16, MapSector*>::iterator si = m_sectors.begin();
1438-
si != m_sectors.end(); ++si)
1439-
{
1438+
si != m_sectors.end(); ++si) {
14401439
MapSector *sector = si->second;
14411440

14421441
bool all_blocks_deleted = true;
@@ -1506,7 +1505,7 @@ void Map::timerUpdate(float dtime, float unload_timeout,
15061505
}
15071506
}
15081507

1509-
void Map::unloadUnreferencedBlocks(std::list<v3s16> *unloaded_blocks)
1508+
void Map::unloadUnreferencedBlocks(std::vector<v3s16> *unloaded_blocks)
15101509
{
15111510
timerUpdate(0.0, -1.0, unloaded_blocks);
15121511
}

Diff for: ‎src/map.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -277,13 +277,13 @@ class Map /*: public NodeContainer*/
277277
Saves modified blocks before unloading on MAPTYPE_SERVER.
278278
*/
279279
void timerUpdate(float dtime, float unload_timeout,
280-
std::list<v3s16> *unloaded_blocks=NULL);
280+
std::vector<v3s16> *unloaded_blocks=NULL);
281281

282282
/*
283283
Unloads all blocks with a zero refCount().
284284
Saves modified blocks before unloading on MAPTYPE_SERVER.
285285
*/
286-
void unloadUnreferencedBlocks(std::list<v3s16> *unloaded_blocks=NULL);
286+
void unloadUnreferencedBlocks(std::vector<v3s16> *unloaded_blocks=NULL);
287287

288288
// Deletes sectors and their blocks from memory
289289
// Takes cache into account

0 commit comments

Comments
 (0)
Please sign in to comment.