Browse Source

Replace array::empty() with array::clear().

We used to have lol::map::empty() to empty maps, but in std::map
this method is called clear(). It sounds safe to harmonise between
our types and have lol::array::clear() too.
legacy
Sam Hocevar 7 years ago
parent
commit
50e494803d
24 changed files with 57 additions and 57 deletions
  1. +4
    -4
      doc/samples/btphystest.cpp
  2. +6
    -6
      doc/samples/meshviewer/meshviewer.cpp
  3. +1
    -1
      doc/samples/meshviewer/scenesetup.cpp
  4. +4
    -4
      doc/samples/physics/lolphysics.h
  5. +2
    -2
      doc/tutorial/12_voronoi.cpp
  6. +1
    -1
      src/easymesh/easymeshbuild.h
  7. +2
    -2
      src/easymesh/easymeshcsg.cpp
  8. +1
    -1
      src/easymesh/easymeshinternal.cpp
  9. +4
    -4
      src/easymesh/easymeshrender.cpp
  10. +3
    -3
      src/easymesh/easymeshtransform.cpp
  11. +1
    -1
      src/engine/ticker.cpp
  12. +1
    -1
      src/gpu/renderer.cpp
  13. +1
    -1
      src/gpu/shader.cpp
  14. +1
    -1
      src/image/image.cpp
  15. +5
    -5
      src/input/controller.cpp
  16. +3
    -3
      src/lol/algorithm/aabb_tree.h
  17. +3
    -3
      src/lol/algorithm/portal.h
  18. +1
    -1
      src/lol/base/array.h
  19. +2
    -2
      src/messageservice.cpp
  20. +1
    -1
      src/platform/nacl/nacl-instance.cpp
  21. +6
    -6
      src/scene.cpp
  22. +2
    -2
      src/sys/threadtypes.cpp
  23. +1
    -1
      src/t/sys/thread.cpp
  24. +1
    -1
      src/tileset.cpp

+ 4
- 4
doc/samples/btphystest.cpp View File

@@ -347,10 +347,10 @@ BtPhysTest::~BtPhysTest()
objects << m_physobj_list.last().m1; objects << m_physobj_list.last().m1;
m_physobj_list.pop(); m_physobj_list.pop();
} }
m_ground_list.empty();
m_stairs_list.empty();
m_character_list.empty();
m_platform_list.empty();
m_ground_list.clear();
m_stairs_list.clear();
m_character_list.clear();
m_platform_list.clear();


while (objects.count()) while (objects.count())
{ {


+ 6
- 6
doc/samples/meshviewer/meshviewer.cpp View File

@@ -75,7 +75,7 @@ LOLFX_RESOURCE_DECLARE(shinymvtexture);
class TargetCamera class TargetCamera
{ {
public: public:
void EmptyTargets() { m_targets.empty(); }
void EmptyTargets() { m_targets.clear(); }
void AddTarget(vec3 new_target) { m_targets << new_target; } void AddTarget(vec3 new_target) { m_targets << new_target; }
//This considers the box usage A to B as top-left to bottom-right //This considers the box usage A to B as top-left to bottom-right
void AddTarget(box3 new_target) void AddTarget(box3 new_target)
@@ -136,7 +136,7 @@ void EasyMeshLoadJob::RetrieveResult(class MeshViewer* app)
{ {
for (EasyMeshViewerObject* mesh : m_meshes) for (EasyMeshViewerObject* mesh : m_meshes)
app->AddViewerObj(mesh); app->AddViewerObj(mesh);
m_meshes.empty();
m_meshes.clear();
} }


//MeshViewer ------------------------------------------------------------------ //MeshViewer ------------------------------------------------------------------
@@ -245,7 +245,7 @@ void MeshViewer::UpdateSceneSetup(bool only_destroy)
//Delete previous setups //Delete previous setups
for (auto &key : m_ssetups) for (auto &key : m_ssetups)
delete key.second; delete key.second;
m_ssetups.empty();
m_ssetups.clear();
if (m_ssetup_file_status) if (m_ssetup_file_status)
{ {
m_file_check->UnregisterFile(m_ssetup_file_status); m_file_check->UnregisterFile(m_ssetup_file_status);
@@ -305,8 +305,8 @@ void MeshViewer::TickGame(float seconds)
//static array<std::string> mesh_names_str; //static array<std::string> mesh_names_str;


//Draw viewer objects //Draw viewer objects
m_menu_mesh_names_char.empty();
m_menu_mesh_names_str.empty();
m_menu_mesh_names_char.clear();
m_menu_mesh_names_str.clear();
for (ViewerObject* obj : m_objs) for (ViewerObject* obj : m_objs)
m_menu_mesh_names_str << obj->GetName(); m_menu_mesh_names_str << obj->GetName();
for (auto const &str : m_menu_mesh_names_str) for (auto const &str : m_menu_mesh_names_str)
@@ -877,7 +877,7 @@ void MeshViewer::Update(float seconds)
} }
} }
} }
m_ssetup->m_custom_cmd.empty();
m_ssetup->m_custom_cmd.clear();
#endif //ALL_FEATURES #endif //ALL_FEATURES


#if HAS_WEB #if HAS_WEB


+ 1
- 1
doc/samples/meshviewer/scenesetup.cpp View File

@@ -58,7 +58,7 @@ bool SceneSetup::Shutdown(bool destroy)
Ticker::Unref(m_lights[i]); Ticker::Unref(m_lights[i]);


if (destroy) if (destroy)
m_lights.empty();
m_lights.clear();
return true; return true;
} }




+ 4
- 4
doc/samples/physics/lolphysics.h View File

@@ -49,10 +49,10 @@ struct RayCastResult
} }
void Reset() void Reset()
{ {
m_collider_list.empty();
m_hit_normal_list.empty();
m_hit_point_list.empty();
m_hit_fraction_list.empty();
m_collider_list.clear();
m_hit_normal_list.clear();
m_hit_point_list.clear();
m_hit_fraction_list.clear();
} }


array<EasyPhysic*> m_collider_list; array<EasyPhysic*> m_collider_list;


+ 2
- 2
doc/tutorial/12_voronoi.cpp View File

@@ -181,7 +181,7 @@ public:
m_cur_fbo = VoronoiFbo; m_cur_fbo = VoronoiFbo;
else if (m_controller->WasKeyReleasedThisFrame(KEY_F3)) else if (m_controller->WasKeyReleasedThisFrame(KEY_F3))
{ {
voronoi_points.empty();
voronoi_points.clear();
if (mode == 0) if (mode == 0)
{ {
int i = 4; int i = 4;
@@ -201,7 +201,7 @@ public:


if (mode == 0) if (mode == 0)
{ {
voronoi_points.empty();
voronoi_points.clear();
int maxi = 6; int maxi = 6;
for (int i = 0; i < maxi; ++i) for (int i = 0; i < maxi; ++i)
{ {


+ 1
- 1
src/easymesh/easymeshbuild.h View File

@@ -536,7 +536,7 @@ public:
void RegisterVertex(int vert_id, vec3 vert_coord); void RegisterVertex(int vert_id, vec3 vert_coord);
void RemoveVertex(int vert_id); void RemoveVertex(int vert_id);
bool GetMasterList(array<int> &ret_master_list) { ret_master_list = master_list; return ret_master_list.count() > 0; } bool GetMasterList(array<int> &ret_master_list) { ret_master_list = master_list; return ret_master_list.count() > 0; }
void Clear() { vertex_list.empty(); }
void Clear() { vertex_list.clear(); }
private: private:
//<VertexId, VertexLocation, VertexMasterId> //<VertexId, VertexLocation, VertexMasterId>
array<int, vec3, int> vertex_list; array<int, vec3, int> vertex_list;


+ 2
- 2
src/easymesh/easymeshcsg.cpp View File

@@ -174,8 +174,8 @@ void EasyMesh::MeshCsg(CSGUsage csg_operation)
} }
} }
#endif #endif
vert_list.empty();
tri_list.empty();
vert_list.clear();
tri_list.clear();
} }
} }




+ 1
- 1
src/easymesh/easymeshinternal.cpp View File

@@ -186,7 +186,7 @@ void EasyMesh::VerticesCleanup()
//2: Remove all unused vertices //2: Remove all unused vertices
array<VertexData> old_vert = m_vert; array<VertexData> old_vert = m_vert;
int shift = 0; int shift = 0;
m_vert.empty();
m_vert.clear();
for (int i = 0; i < vert_ids.count(); ++i) for (int i = 0; i < vert_ids.count(); ++i)
{ {
//Unused vertex, update the shift quantity instead of keeping it. //Unused vertex, update the shift quantity instead of keeping it.


+ 4
- 4
src/easymesh/easymeshrender.cpp View File

@@ -88,8 +88,8 @@ GpuShaderData::GpuShaderData(uint16_t vert_decl_flags, Shader* shader, DebugRend
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
GpuShaderData::~GpuShaderData() GpuShaderData::~GpuShaderData()
{ {
m_shader_uniform.empty();
m_shader_attrib.empty();
m_shader_uniform.clear();
m_shader_attrib.clear();
} }


//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -228,8 +228,8 @@ GpuEasyMeshData::GpuEasyMeshData()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
GpuEasyMeshData::~GpuEasyMeshData() GpuEasyMeshData::~GpuEasyMeshData()
{ {
m_gpudatas.empty();
m_vdatas.empty();
m_gpudatas.clear();
m_vdatas.clear();
if (m_ibo) if (m_ibo)
delete m_ibo; delete m_ibo;
} }


+ 3
- 3
src/easymesh/easymeshtransform.cpp View File

@@ -397,12 +397,12 @@ void EasyMesh::SmoothMesh(int main_pass, int split_per_main_pass, int smooth_per


while (smooth_pass--) while (smooth_pass--)
{ {
master_list.empty();
master_list.clear();
if (vert_dict.GetMasterList(master_list)) if (vert_dict.GetMasterList(master_list))
{ {
for (int i = 0; i < master_list.count(); i++) for (int i = 0; i < master_list.count(); i++)
{ {
connected_vert.empty();
connected_vert.clear();
if (vert_dict.FindConnectedVertices(master_list[i], m_indices, m_cursors.last().m2, connected_vert)) if (vert_dict.FindConnectedVertices(master_list[i], m_indices, m_cursors.last().m2, connected_vert))
{ {
//Calculate vertices sum //Calculate vertices sum
@@ -421,7 +421,7 @@ void EasyMesh::SmoothMesh(int main_pass, int split_per_main_pass, int smooth_per
vec3 new_vert = (alpha * smooth_buf[smbuf][master_list[i] - m_cursors.last().m1] + vert_sum) / (alpha + n); vec3 new_vert = (alpha * smooth_buf[smbuf][master_list[i] - m_cursors.last().m1] + vert_sum) / (alpha + n);


//Set all matching vertices to new value //Set all matching vertices to new value
matching_ids.empty();
matching_ids.clear();
matching_ids << master_list[i]; matching_ids << master_list[i];
vert_dict.FindMatchingVertices(master_list[i], matching_ids); vert_dict.FindMatchingVertices(master_list[i], matching_ids);
for (int j = 0; j < matching_ids.count(); j++) for (int j = 0; j < matching_ids.count(); j++)


+ 1
- 1
src/engine/ticker.cpp View File

@@ -388,7 +388,7 @@ void TickerData::GameThreadTick()
} }


data->m_todolist = data->m_todolist_delayed; data->m_todolist = data->m_todolist_delayed;
data->m_todolist_delayed.empty();
data->m_todolist_delayed.clear();


/* Tick objects for the game loop */ /* Tick objects for the game loop */
for (int g = Entity::GAMEGROUP_BEGIN; g < Entity::GAMEGROUP_END && !data->quit /* Stop as soon as required */; ++g) for (int g = Entity::GAMEGROUP_BEGIN; g < Entity::GAMEGROUP_END && !data->quit /* Stop as soon as required */; ++g)


+ 1
- 1
src/gpu/renderer.cpp View File

@@ -165,7 +165,7 @@ void Renderer::DestroyAll()
{ {
for (Renderer* renderer : g_renderers) for (Renderer* renderer : g_renderers)
delete renderer; delete renderer;
g_renderers.empty();
g_renderers.clear();
} }


/* /*


+ 1
- 1
src/gpu/shader.cpp View File

@@ -982,7 +982,7 @@ void ShaderBuilder::Build(std::string& code)
//Cleanup first //Cleanup first
for (int prog = 0; prog < ShaderProgram::MAX; prog++) for (int prog = 0; prog < ShaderProgram::MAX; prog++)
for (int var = 0; var < ShaderVariable::MAX; var++) for (int var = 0; var < ShaderVariable::MAX; var++)
m_parameters[prog][var].empty();
m_parameters[prog][var].clear();


//Start building //Start building
for (int prog = 0; prog < ShaderProgram::MAX; prog++) for (int prog = 0; prog < ShaderProgram::MAX; prog++)


+ 1
- 1
src/image/image.cpp View File

@@ -131,7 +131,7 @@ void image::resize(ivec2 size)
{ {
for (auto &kv : m_data->m_pixels) for (auto &kv : m_data->m_pixels)
delete kv.second; delete kv.second;
m_data->m_pixels.empty();
m_data->m_pixels.clear();
m_data->m_format = PixelFormat::Unknown; m_data->m_format = PixelFormat::Unknown;
} }




+ 5
- 5
src/input/controller.cpp View File

@@ -61,7 +61,7 @@ bool KeyBinding::Unbind(const std::string& device_name, const std::string& key_n


void KeyBinding::ClearBindings() void KeyBinding::ClearBindings()
{ {
m_keybindings.empty();
m_keybindings.clear();
} }


/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@@ -190,8 +190,8 @@ bool AxisBinding::UnbindKeys(const std::string& device_name, const std::string&


void AxisBinding::ClearBindings() void AxisBinding::ClearBindings()
{ {
m_axisbindings.empty();
m_keybindings.empty();
m_axisbindings.clear();
m_keybindings.clear();
} }


float AxisBinding::RetrieveCurrentValue() float AxisBinding::RetrieveCurrentValue()
@@ -390,8 +390,8 @@ void Controller::UnbindProfile()
if (m_joystick_idx.find(axis.m_joy) != INDEX_NONE) if (m_joystick_idx.find(axis.m_joy) != INDEX_NONE)
GetAxis(axis.m_idx).UnbindJoystick(axis.m_joy, axis.m_name); GetAxis(axis.m_idx).UnbindJoystick(axis.m_joy, axis.m_name);
} }
m_joystick.empty();
m_joystick_idx.empty();
m_joystick.clear();
m_joystick_idx.clear();


m_mutex.unlock(); m_mutex.unlock();
} }


+ 3
- 3
src/lol/algorithm/aabb_tree.h View File

@@ -302,7 +302,7 @@ private:
//Extract elements //Extract elements
array<int> elements = m_tree[leaf].m_elements; array<int> elements = m_tree[leaf].m_elements;
elements.push_unique(AddElement(element)); elements.push_unique(AddElement(element));
m_tree[leaf].m_elements.empty();
m_tree[leaf].m_elements.clear();
//Add children //Add children
for (size_t j = 0; j < child_nb; ++j) for (size_t j = 0; j < child_nb; ++j)
m_tree[leaf].m_children[j] = AddLeaf(leaf); m_tree[leaf].m_children[j] = AddLeaf(leaf);
@@ -331,8 +331,8 @@ public:
bool FindElements(const TB& bbox, array<TE*>& elements) { return TestLeaf(0, GetAABB(), bbox, elements); } bool FindElements(const TB& bbox, array<TE*>& elements) { return TestLeaf(0, GetAABB(), bbox, elements); }
void Clear() void Clear()
{ {
m_tree.empty();
m_elements.empty();
m_tree.clear();
m_elements.clear();
} }


//-- //--


+ 3
- 3
src/lol/algorithm/portal.h View File

@@ -260,7 +260,7 @@ public:
{ {
for (auto door : m_doors) for (auto door : m_doors)
door->DisconnectRoom(this); door->DisconnectRoom(this);
m_doors.empty();
m_doors.clear();
} }


PortalRoom& operator<<(class PortalDoor<TE>* door) PortalRoom& operator<<(class PortalDoor<TE>* door)
@@ -294,8 +294,8 @@ public:
delete door; delete door;
for (auto room : m_rooms) for (auto room : m_rooms)
delete room; delete room;
m_doors.empty();
m_rooms.empty();
m_doors.clear();
m_rooms.clear();
} }


//Visible room getter //Visible room getter


+ 1
- 1
src/lol/base/array.h View File

@@ -367,7 +367,7 @@ public:
m_count = item_count; m_count = item_count;
} }


inline void empty()
inline void clear()
{ {
remove(0, m_count); remove(0, m_count);
} }


+ 2
- 2
src/messageservice.cpp View File

@@ -45,7 +45,7 @@ MessageService::MessageService()


MessageService::~MessageService() MessageService::~MessageService()
{ {
m_bucket.empty();
m_bucket.clear();
} }


//Setup/Destroy //Setup/Destroy
@@ -131,7 +131,7 @@ bool MessageService::FetchAll(MessageBucket id, std::string& message, time_t& fi
first_timestamp = bucket[0].m_timestamp; first_timestamp = bucket[0].m_timestamp;
for (int i = 0; i < bucket.count(); ++i) for (int i = 0; i < bucket.count(); ++i)
message += bucket[i].m_message; message += bucket[i].m_message;
bucket.empty();
bucket.clear();
return true; return true;
} }
} }


+ 1
- 1
src/platform/nacl/nacl-instance.cpp View File

@@ -223,7 +223,7 @@ void NaClInputData::Tick(float seconds)
} }
} }
} }
m_input_events.empty();
m_input_events.clear();


/* Handle mouse input */ /* Handle mouse input */
if (IsViewportSizeValid()) if (IsViewportSizeValid())


+ 6
- 6
src/scene.cpp View File

@@ -89,7 +89,7 @@ void SceneDisplay::DestroyAll()
{ {
for (SceneDisplay* display : m_scene_displays) for (SceneDisplay* display : m_scene_displays)
delete display; delete display;
m_scene_displays.empty();
m_scene_displays.clear();
} }


/* ------------------------------------------------ */ /* ------------------------------------------------ */
@@ -374,9 +374,9 @@ void Scene::Reset()


for (int i = 0; i < data->m_tile_api.m_bufs.count(); i++) for (int i = 0; i < data->m_tile_api.m_bufs.count(); i++)
delete data->m_tile_api.m_bufs[i]; delete data->m_tile_api.m_bufs[i];
data->m_tile_api.m_bufs.empty();
data->m_tile_api.m_bufs.clear();


data->m_tile_api.m_lights.empty();
data->m_tile_api.m_lights.clear();
} }


//---- Primitive source stuff ------------------------------------------------- //---- Primitive source stuff -------------------------------------------------
@@ -446,7 +446,7 @@ void Scene::ReleaseAllPrimitiveSources(uintptr_t key)
oldies.reserve(SceneData::m_prim_sources[key].count()); oldies.reserve(SceneData::m_prim_sources[key].count());
for (PrimitiveSource* source : SceneData::m_prim_sources[key]) for (PrimitiveSource* source : SceneData::m_prim_sources[key])
oldies << source; oldies << source;
SceneData::m_prim_sources[key].empty();
SceneData::m_prim_sources[key].clear();
} }
SceneData::m_prim_mutex.unlock(); SceneData::m_prim_mutex.unlock();


@@ -807,7 +807,7 @@ void Scene::render_tiles() // XXX: rename to Blit()
tiles[i].m_tileset->Unbind(); tiles[i].m_tileset->Unbind();
} }


tiles.empty();
tiles.clear();


shader->Unbind(); shader->Unbind();


@@ -888,7 +888,7 @@ void Scene::render_lines(float seconds)
data->m_line_api.m_vdecl->Unbind(); data->m_line_api.m_vdecl->Unbind();
data->m_line_api.m_shader->Unbind(); data->m_line_api.m_shader->Unbind();


//data->m_line_api.m_lines.empty();
//data->m_line_api.m_lines.clear();
delete vb; delete vb;
} }




+ 2
- 2
src/sys/threadtypes.cpp View File

@@ -23,7 +23,7 @@ void DefaultThreadManager::AddJob(ThreadJob* job)
bool DefaultThreadManager::GetWorkResult(array<ThreadJob*>& results) bool DefaultThreadManager::GetWorkResult(array<ThreadJob*>& results)
{ {
results += m_job_result; results += m_job_result;
m_job_result.empty();
m_job_result.clear();
return results.count() > 0; return results.count() > 0;
} }


@@ -140,7 +140,7 @@ void FileUpdateTester::TickGame(float seconds)
m_frame_count = 0; m_frame_count = 0;


DispatchJob(m_job_done); DispatchJob(m_job_done);
m_job_done.empty();
m_job_done.clear();
} }
} }




+ 1
- 1
src/t/sys/thread.cpp View File

@@ -93,7 +93,7 @@ lolunit_declare_fixture(thread_test)
bool GetWorkResult(array<ThreadJob*>& results) bool GetWorkResult(array<ThreadJob*>& results)
{ {
results += m_job_result; results += m_job_result;
m_job_result.empty();
m_job_result.clear();
msg::info("%s GETWORKRESULT (%i)\n", GetName().c_str(), results.count()); msg::info("%s GETWORKRESULT (%i)\n", GetName().c_str(), results.count());
return results.count() > 0; return results.count() > 0;
} }


+ 1
- 1
src/tileset.cpp View File

@@ -148,7 +148,7 @@ std::string TileSet::GetName() const
//New methods ----------------------------------------------------------------- //New methods -----------------------------------------------------------------
void TileSet::clear_all() void TileSet::clear_all()
{ {
m_tileset_data->m_tiles.empty();
m_tileset_data->m_tiles.clear();
} }


int TileSet::define_tile(ibox2 rect) int TileSet::define_tile(ibox2 rect)


Loading…
Cancel
Save