Skip to content

Commit 40b251b

Browse files
committed
Merge pull request #103899 from Ivorforce/idiomatic-template-vargs
Use idiomatic templating vargs in a few places to reduce code.
2 parents 6d08aa4 + df7dab4 commit 40b251b

File tree

3 files changed

+4
-38
lines changed

3 files changed

+4
-38
lines changed

core/object/class_db.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -542,13 +542,8 @@ class ClassDB {
542542

543543
#ifdef DEBUG_ENABLED
544544

545-
template <typename... P>
546-
_FORCE_INLINE_ Vector<Error> errarray(P... p_args) {
547-
return Vector<Error>({ p_args... });
548-
}
549-
550545
#define BIND_METHOD_ERR_RETURN_DOC(m_method, ...) \
551-
::ClassDB::set_method_error_return_values(get_class_static(), m_method, errarray(__VA_ARGS__));
546+
::ClassDB::set_method_error_return_values(get_class_static(), m_method, Vector<Error>{ __VA_ARGS__ });
552547

553548
#else
554549

servers/rendering/renderer_rd/framebuffer_cache_rd.h

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -137,16 +137,6 @@ class FramebufferCacheRD : public Object {
137137
return _compare_args(idx + 1, textures, args...);
138138
}
139139

140-
_FORCE_INLINE_ void _create_args(Vector<RID> &textures, const RID &arg) {
141-
textures.push_back(arg);
142-
}
143-
144-
template <typename... Args>
145-
_FORCE_INLINE_ void _create_args(Vector<RID> &textures, const RID &arg, Args... args) {
146-
textures.push_back(arg);
147-
_create_args(textures, args...);
148-
}
149-
150140
static FramebufferCacheRD *singleton;
151141

152142
uint32_t cache_instances_used = 0;
@@ -216,10 +206,7 @@ class FramebufferCacheRD : public Object {
216206

217207
// Not in cache, create:
218208

219-
Vector<RID> textures;
220-
_create_args(textures, args...);
221-
222-
return _allocate_from_data(1, h, table_idx, textures, Vector<RD::FramebufferPass>());
209+
return _allocate_from_data(1, h, table_idx, Vector<RID>{ args... }, Vector<RD::FramebufferPass>());
223210
}
224211

225212
template <typename... Args>
@@ -244,10 +231,7 @@ class FramebufferCacheRD : public Object {
244231

245232
// Not in cache, create:
246233

247-
Vector<RID> textures;
248-
_create_args(textures, args...);
249-
250-
return _allocate_from_data(p_views, h, table_idx, textures, Vector<RD::FramebufferPass>());
234+
return _allocate_from_data(p_views, h, table_idx, Vector<RID>{ args... }, Vector<RD::FramebufferPass>());
251235
}
252236

253237
RID get_cache_multipass(const Vector<RID> &p_textures, const Vector<RD::FramebufferPass> &p_passes, uint32_t p_views = 1) {

servers/rendering/renderer_rd/uniform_set_cache_rd.h

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -107,16 +107,6 @@ class UniformSetCacheRD : public Object {
107107
return _compare_args(idx + 1, uniforms, args...);
108108
}
109109

110-
_FORCE_INLINE_ void _create_args(Vector<RD::Uniform> &uniforms, const RD::Uniform &arg) {
111-
uniforms.push_back(arg);
112-
}
113-
114-
template <typename... Args>
115-
_FORCE_INLINE_ void _create_args(Vector<RD::Uniform> &uniforms, const RD::Uniform &arg, Args... args) {
116-
uniforms.push_back(arg);
117-
_create_args(uniforms, args...);
118-
}
119-
120110
static UniformSetCacheRD *singleton;
121111

122112
uint32_t cache_instances_used = 0;
@@ -176,10 +166,7 @@ class UniformSetCacheRD : public Object {
176166

177167
// Not in cache, create:
178168

179-
Vector<RD::Uniform> uniforms;
180-
_create_args(uniforms, args...);
181-
182-
return _allocate_from_uniforms(p_shader, p_set, h, table_idx, uniforms);
169+
return _allocate_from_uniforms(p_shader, p_set, h, table_idx, Vector<RD::Uniform>{ args... });
183170
}
184171

185172
template <typename... Args>

0 commit comments

Comments
 (0)