Browse Source

usage of list resize

Kajetan Johannes Hammerle 3 years ago
parent
commit
fe1f68eadb
2 changed files with 1 additions and 7 deletions
  1. 1 3
      common/world/BlockMap.cpp
  2. 0 4
      common/world/BlockStorage.cpp

+ 1 - 3
common/world/BlockMap.cpp

@@ -26,9 +26,7 @@ void BlockMap::set(int index, BlockId id) {
     }
     blocks.resize(blocks.getBits() + 1);
     int mapId = map.getLength();
-    for(int i = 0; i < mapId; i++) {
-        map.add(EMPTY_BLOCK);
-    }
+    map.resize(mapId * 2, EMPTY_BLOCK);
     map[mapId] = id;
     blocks.set(index, mapId);
 }

+ 0 - 4
common/world/BlockStorage.cpp

@@ -6,11 +6,7 @@ static constexpr int SEGMENT_MASK = (1 << SEGMENT_BITS) - 1;
 
 BlockStorage::BlockStorage(int sizeBits, int heightBits)
     : size(1 << sizeBits), height(1 << heightBits), sizeMask(size - 1) {
-    // int pointers = (size * size * height) / SEGMENT;
     maps.resize((size * size * height) / SEGMENT);
-    // for(int i = 0; i < pointers; i++) {
-    //    maps.add();
-    //}
 }
 
 BlockId BlockStorage::get(int x, int y, int z) const {