1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-11-25 11:52:40 +01:00

size() -> empty()

Empty has always
computational complexity O(1).
This commit is contained in:
Filip Gawin 2017-11-08 17:41:55 +01:00 committed by Daniel Evans
parent 66b576dcee
commit ef4456e623
9 changed files with 16 additions and 13 deletions

View File

@ -45,7 +45,7 @@ void Animator::tick(float dt) {
}
for (auto& b : state.boneInstances) {
if (b.first->frames.size() == 0) continue;
if (b.first->frames.empty()) continue;
auto kf = b.first->getInterpolatedKeyframe(animTime);
BoneTransform xform;

View File

@ -86,7 +86,7 @@ void GameData::loadLevelFile(const std::string& path) {
currenttextureslot = "generic";
for (std::string line, cmd; std::getline(datfile, line);) {
if (line.size() == 0 || line[0] == '#') continue;
if (line.empty() || line[0] == '#') continue;
#ifndef RW_WINDOWS
line.erase(line.size() - 1);
#endif

View File

@ -258,7 +258,7 @@ VehicleObject* GameWorld::createVehicle(const uint16_t id, const glm::vec3& pos,
glm::u8vec3 prim(255), sec(128);
auto palit = data->vehiclePalettes.find(
vti->name); // modelname is conveniently lowercase (usually)
if (palit != data->vehiclePalettes.end() && palit->second.size() > 0) {
if (palit != data->vehiclePalettes.end() && !palit->second.empty()) {
std::uniform_int_distribution<int> uniform(0, palit->second.size() - 1);
int set = uniform(randomEngine);
prim = data->vehicleColours[palit->second[set].first];
@ -270,7 +270,7 @@ VehicleObject* GameWorld::createVehicle(const uint16_t id, const glm::vec3& pos,
auto model = vti->getModel();
auto info = data->vehicleInfo.find(vti->handling_);
if (model && info != data->vehicleInfo.end() &&
info->second->wheels.size() == 0 && info->second->seats.size() == 0) {
info->second->wheels.empty() && info->second->seats.empty()) {
auto root = model->getFrame();
for (const auto& frame : root->getChildren()) {
const std::string& name = frame->getName();

View File

@ -97,6 +97,9 @@ struct VehicleInfo {
size_t size() const {
return front.size() + back.size();
}
bool empty() const {
return front.empty() && back.empty();
}
} seats;
};

View File

@ -51,7 +51,7 @@ void DebugDraw::drawContactPoint(const btVector3 &pointOnB,
}
void DebugDraw::flush(GameRenderer *renderer) {
if (lines.size() == 0) {
if (lines.empty()) {
return;
}

View File

@ -401,7 +401,7 @@ void GameRenderer::renderWorld(GameWorld* world, const ViewCamera& camera,
GLuint splashTexName = 0;
auto fc = world->state->fadeColour;
if ((fc.r + fc.g + fc.b) == 0 && world->state->currentSplash.size() > 0) {
if ((fc.r + fc.g + fc.b) == 0 && !world->state->currentSplash.empty()) {
auto splash = world->data->findSlotTexture("generic", world->state->currentSplash);
if (splash) {
splashTexName = splash->getName();

View File

@ -31,7 +31,7 @@ RenderKey createKey(bool transparent, float normalizedDepth,
uint32_t(0x7FFFFF *
(transparent ? 1.f - normalizedDepth : normalizedDepth))
<< 8 |
uint8_t(0xFF & (textures.size() > 0 ? textures[0] : 0)) << 0;
uint8_t(0xFF & (!textures.empty() ? textures[0] : 0)) << 0;
}
void ObjectRenderer::renderGeometry(Geometry* geom,
@ -57,7 +57,7 @@ void ObjectRenderer::renderGeometry(Geometry* geom,
if (geom->materials.size() > subgeom.material) {
Geometry::Material& mat = geom->materials[subgeom.material];
if (mat.textures.size() > 0) {
if (!mat.textures.empty()) {
auto tex = mat.textures[0].texture;
if (tex) {
if (tex->isTransparent()) {

View File

@ -403,13 +403,13 @@ std::string GameConfig::ParseResult::what() const {
break;
case ErrorType::INVALIDCONTENT:
oss << "Error while parsing \"" << this->m_inputfilename << "\".";
if (this->m_keys_requiredMissing.size()) {
if (!this->m_keys_requiredMissing.empty()) {
oss << "\nRequired keys that are missing:";
for (auto &key : this->m_keys_requiredMissing) {
oss << "\n - " << key;
}
}
if (this->m_keys_invalidData.size()) {
if (!this->m_keys_invalidData.empty()) {
oss << "\nKeys that contain invalid data:";
for (auto &key : this->m_keys_invalidData) {
oss << "\n - " << key;
@ -420,7 +420,7 @@ std::string GameConfig::ParseResult::what() const {
oss << "Unknown error.";
break;
}
if (this->m_unknownData.size()) {
if (!this->m_unknownData.empty()) {
oss << "\nUnknown configuration keys:";
for (const auto &keyvalue : m_unknownData) {
oss << "\n - " << keyvalue.first;

View File

@ -41,7 +41,7 @@ void BenchmarkState::enter() {
if (!benchstream) break;
benchstream >> point.angle.w;
if (!benchstream) break;
if (track.size() == 0) {
if (track.empty()) {
tmpPos = point.position;
}
float pointDist = glm::distance(tmpPos, point.position);
@ -66,7 +66,7 @@ void BenchmarkState::exit() {
}
void BenchmarkState::tick(float dt) {
if (track.size() > 0) {
if (!track.empty()) {
TrackPoint& a = track.front();
TrackPoint& b = track.back();
for (TrackPoint& p : track) {