Sam Hocevar sam 12 лет назад
Родитель
Сommit
0b7c51b992
2 измененных файлов: 32 добавлений и 5 удалений
  1. +31
    -4
      src/array.h
  2. +1
    -1
      src/ticker.cpp

+ 31
- 4
src/array.h Просмотреть файл

@@ -44,7 +44,14 @@ public:
{
for (int i = 0; i < m_count; i++)
m_data[i].~Element();
delete[] reinterpret_cast<uint8_t *>(m_data);
if (sizeof(Element) & 1)
delete[] (uint8_t *)(m_data);
else if (sizeof(Element) & 2)
delete[] (uint16_t *)(m_data);
else if (sizeof(Element) & 4)
delete[] (uint32_t *)(m_data);
else
delete[] (uint64_t *)(m_data);
}

ArrayBase(ArrayBase const& that) : m_data(0), m_count(0), m_reserved(0)
@@ -174,15 +181,35 @@ public:
if (toreserve <= (int)m_reserved)
return;

Element *tmp = reinterpret_cast<Element *>
(new uint8_t [sizeof(Element) * toreserve]);
Element *tmp;
if (sizeof(Element) & 1)
tmp = (Element *)
(new uint8_t [sizeof(Element) * toreserve]);
else if (sizeof(Element) & 2)
tmp = (Element *)
(new uint16_t [sizeof(Element) / 2 * toreserve]);
else if (sizeof(Element) & 4)
tmp = (Element *)
(new uint32_t [sizeof(Element) / 4 * toreserve]);
else
tmp = (Element *)
(new uint64_t [sizeof(Element) / 8 * toreserve]);
for (int i = 0; i < m_count; i++)
{
new(&tmp[i]) Element(m_data[i]);
m_data[i].~Element();
}
if (m_data)
delete[] reinterpret_cast<uint8_t *>(m_data);
{
if (sizeof(Element) & 1)
delete[] (uint8_t *)(m_data);
else if (sizeof(Element) & 2)
delete[] (uint16_t *)(m_data);
else if (sizeof(Element) & 4)
delete[] (uint32_t *)(m_data);
else
delete[] (uint64_t *)(m_data);
}
m_data = tmp;
m_reserved = toreserve;
}


+ 1
- 1
src/ticker.cpp Просмотреть файл

@@ -165,7 +165,7 @@ void *TickerData::GameThreadMain(void * /* p */)

Profiler::Start(Profiler::STAT_TICK_GAME);

#if 0
#if 1
Log::Debug("-------------------------------------\n");
for (int i = 0; i < Entity::ALLGROUP_END; i++)
{


Загрузка…
Отмена
Сохранить