Skip to content

Commit 4f4031a

Browse files
committed
Replace size() == 0 with is_empty().
1 parent c7ea861 commit 4f4031a

File tree

147 files changed

+300
-300
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

147 files changed

+300
-300
lines changed

core/debugger/local_debugger.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ void LocalDebugger::debug(bool p_can_continue, bool p_is_error_breakpoint) {
242242
} else if (line.begins_with("br") || line.begins_with("break")) {
243243
if (line.get_slice_count(" ") <= 1) {
244244
const HashMap<int, HashSet<StringName>> &breakpoints = script_debugger->get_breakpoints();
245-
if (breakpoints.size() == 0) {
245+
if (breakpoints.is_empty()) {
246246
print_line("No Breakpoints.");
247247
continue;
248248
}

core/debugger/remote_debugger_peer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ void RemoteDebuggerPeerTCP::_write_out() {
9696
while (tcp_client->get_status() == StreamPeerTCP::STATUS_CONNECTED && tcp_client->wait(NetSocket::POLL_TYPE_OUT) == OK) {
9797
uint8_t *buf = out_buf.ptrw();
9898
if (out_left <= 0) {
99-
if (out_queue.size() == 0) {
99+
if (out_queue.is_empty()) {
100100
break; // Nothing left to send
101101
}
102102
mutex.lock();

core/debugger/script_debugger.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ void ScriptDebugger::remove_breakpoint(int p_line, const StringName &p_source) {
5858
}
5959

6060
breakpoints[p_line].erase(p_source);
61-
if (breakpoints[p_line].size() == 0) {
61+
if (breakpoints[p_line].is_empty()) {
6262
breakpoints.erase(p_line);
6363
}
6464
}

core/doc_data.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ class DocData {
114114
// Must be an operator or a constructor since there is no other overloading
115115
if (name.left(8) == "operator") {
116116
if (arguments.size() == p_method.arguments.size()) {
117-
if (arguments.size() == 0) {
117+
if (arguments.is_empty()) {
118118
return false;
119119
}
120120
return arguments[0].type < p_method.arguments[0].type;
@@ -126,7 +126,7 @@ class DocData {
126126
// - 1. Default constructor: Foo()
127127
// - 2. Copy constructor: Foo(Foo)
128128
// - 3+. Other constructors Foo(Bar, ...) based on first argument's name
129-
if (arguments.size() == 0 || p_method.arguments.size() == 0) { // 1.
129+
if (arguments.is_empty() || p_method.arguments.is_empty()) { // 1.
130130
return arguments.size() < p_method.arguments.size();
131131
}
132132
if (arguments[0].type == return_type || p_method.arguments[0].type == p_method.return_type) { // 2.

core/io/image.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ static bool _are_formats_compatible(Image::Format p_format0, Image::Format p_for
573573
void Image::convert(Format p_new_format) {
574574
ERR_FAIL_INDEX_MSG(p_new_format, FORMAT_MAX, vformat("The Image format specified (%d) is out of range. See Image's Format enum.", p_new_format));
575575

576-
if (data.size() == 0 || p_new_format == format) {
576+
if (data.is_empty() || p_new_format == format) {
577577
return;
578578
}
579579

@@ -2177,7 +2177,7 @@ void Image::clear_mipmaps() {
21772177
}
21782178

21792179
bool Image::is_empty() const {
2180-
return (data.size() == 0);
2180+
return (data.is_empty());
21812181
}
21822182

21832183
Vector<uint8_t> Image::get_data() const {
@@ -3096,7 +3096,7 @@ void Image::_repeat_pixel_over_subsequent_memory(uint8_t *p_pixel, int p_pixel_s
30963096
}
30973097

30983098
void Image::fill(const Color &p_color) {
3099-
if (data.size() == 0) {
3099+
if (data.is_empty()) {
31003100
return;
31013101
}
31023102
ERR_FAIL_COND_MSG(is_compressed(), "Cannot fill in compressed image formats.");
@@ -3112,7 +3112,7 @@ void Image::fill(const Color &p_color) {
31123112
}
31133113

31143114
void Image::fill_rect(const Rect2i &p_rect, const Color &p_color) {
3115-
if (data.size() == 0) {
3115+
if (data.is_empty()) {
31163116
return;
31173117
}
31183118
ERR_FAIL_COND_MSG(is_compressed(), "Cannot fill rect in compressed image formats.");
@@ -3734,7 +3734,7 @@ void Image::normal_map_to_xy() {
37343734
}
37353735

37363736
Ref<Image> Image::rgbe_to_srgb() {
3737-
if (data.size() == 0) {
3737+
if (data.is_empty()) {
37383738
return Ref<Image>();
37393739
}
37403740

@@ -3856,7 +3856,7 @@ bool Image::detect_signed(bool p_include_mips) const {
38563856
}
38573857

38583858
void Image::srgb_to_linear() {
3859-
if (data.size() == 0) {
3859+
if (data.is_empty()) {
38603860
return;
38613861
}
38623862

@@ -3887,7 +3887,7 @@ void Image::srgb_to_linear() {
38873887
}
38883888

38893889
void Image::linear_to_srgb() {
3890-
if (data.size() == 0) {
3890+
if (data.is_empty()) {
38913891
return;
38923892
}
38933893

@@ -3918,7 +3918,7 @@ void Image::linear_to_srgb() {
39183918
}
39193919

39203920
void Image::premultiply_alpha() {
3921-
if (data.size() == 0) {
3921+
if (data.is_empty()) {
39223922
return;
39233923
}
39243924

@@ -3940,7 +3940,7 @@ void Image::premultiply_alpha() {
39403940
}
39413941

39423942
void Image::fix_alpha_edges() {
3943-
if (data.size() == 0) {
3943+
if (data.is_empty()) {
39443944
return;
39453945
}
39463946

core/math/bvh.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ class BVH_Manager {
406406
}
407407

408408
Vector<Vector3> convex_points = Geometry3D::compute_convex_mesh_points(&p_convex[0], p_convex.size());
409-
if (convex_points.size() == 0) {
409+
if (convex_points.is_empty()) {
410410
return 0;
411411
}
412412

core/math/convex_hull.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2237,7 +2237,7 @@ real_t ConvexHullComputer::compute(const Vector3 *p_coords, int32_t p_count, rea
22372237
Error ConvexHullComputer::convex_hull(const Vector<Vector3> &p_points, Geometry3D::MeshData &r_mesh) {
22382238
r_mesh = Geometry3D::MeshData(); // clear
22392239

2240-
if (p_points.size() == 0) {
2240+
if (p_points.is_empty()) {
22412241
return FAILED; // matches QuickHull
22422242
}
22432243

core/math/geometry_3d.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ class Geometry3D {
484484
LOC_OUTSIDE = -1
485485
};
486486

487-
if (polygon.size() == 0) {
487+
if (polygon.is_empty()) {
488488
return polygon;
489489
}
490490

core/math/quick_hull.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ Error QuickHull::build(const Vector<Vector3> &p_points, Geometry3D::MeshData &r_
323323

324324
for (List<Face>::Element *&E : new_faces) {
325325
Face &f2 = E->get();
326-
if (f2.points_over.size() == 0) {
326+
if (f2.points_over.is_empty()) {
327327
faces.move_to_front(E);
328328
}
329329
}

core/object/message_queue.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ void CallQueue::_call_function(const Callable &p_callable, const Variant *p_args
226226
Error CallQueue::flush() {
227227
LOCK_MUTEX;
228228

229-
if (pages.size() == 0) {
229+
if (pages.is_empty()) {
230230
// Never allocated
231231
UNLOCK_MUTEX;
232232
return OK; // Do nothing.
@@ -308,7 +308,7 @@ Error CallQueue::flush() {
308308
void CallQueue::clear() {
309309
LOCK_MUTEX;
310310

311-
if (pages.size() == 0) {
311+
if (pages.is_empty()) {
312312
UNLOCK_MUTEX;
313313
return; // Nothing to clear.
314314
}

0 commit comments

Comments
 (0)