Skip to content

Commit e1df62b

Browse files
DinoVmeta-codesync[bot]
authored andcommitted
Small call optimizations
Summary: carlosatorres caught this while looking at some ARM perf. For `JITRT_BindKeywordArgs` our memory is already zero-initialized by `std::unique_ptr`. For `JITRT_BindKeywordArgsSimple` we don't need to zero the memory for the values that exist. Reviewed By: mpage Differential Revision: D109753053 fbshipit-source-id: c7637385642fce54de647bda07f9e22cddecb106
1 parent 1b715fc commit e1df62b

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

cinderx/Jit/jit_rt.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ static int JITRT_BindKeywordArgs(
156156
Py_ssize_t argcount = PyVectorcall_NARGS(nargsf);
157157

158158
for (int i = 0; i < arg_space.size(); i++) {
159-
arg_space[i] = nullptr;
159+
JIT_DCHECK(arg_space[i] == nullptr, "should be initialized");
160160
}
161161

162162
// Copy all positional arguments into local variables
@@ -245,16 +245,17 @@ static int JITRT_BindKeywordArgsSimple(
245245
return 0;
246246
}
247247

248-
for (int i = 0; i < arg_space.size(); i++) {
249-
arg_space[i] = nullptr;
250-
}
251-
252248
// Copy all positional arguments into local variables
253249
Py_ssize_t n = std::min<Py_ssize_t>(argcount, co->co_argcount);
250+
254251
for (Py_ssize_t j = 0; j < n; j++) {
255252
arg_space[j] = args[j];
256253
}
257254

255+
for (int i = n; i < arg_space.size(); i++) {
256+
arg_space[i] = nullptr;
257+
}
258+
258259
// Check the number of positional arguments
259260
return JITRT_BindKeywords(args, kwnames, arg_space, argcount, co, nullptr) &&
260261
JITRT_BindDefaults(argcount, arg_space, co, func);

0 commit comments

Comments
 (0)