Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 53cb896

Browse files
Generated arginfo header files: remove empty zend_function_entry arrays (#15705)
When a class (or enum) has no methods, rather than using an array that only contains `ZEND_FE_END`, use `NULL` for the functions. The implementation of class registration for internal classes, `do_register_internal_class()` in zend_API.c, already skips classes where the functions are `NULL`. By removing these unneeded arrays, we can reduce the size of the header files, while also removing an unneeded call to zend_register_functions() for each internal class with no extra methods.
1 parent 7dfbf4d commit 53cb896

Some content is hidden

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

48 files changed

+127
-591
lines changed

‎Zend/zend_builtin_functions_arginfo.h‎

Lines changed: 1 addition & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Zend/zend_exceptions_arginfo.h‎

Lines changed: 9 additions & 45 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Zend/zend_generators_arginfo.h‎

Lines changed: 1 addition & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Zend/zend_interfaces_arginfo.h‎

Lines changed: 1 addition & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎build/gen_stub.php‎

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3285,11 +3285,12 @@ public function getRegistration(array $allConstInfos): string
32853285
$flagCodes = generateVersionDependentFlagCode("%s", $this->getFlagsByPhpVersion(), $this->phpVersionIdMinimumCompatibility);
32863286
$flags = implode("", $flagCodes);
32873287

3288+
$classMethods = ($this->funcInfos === []) ? 'NULL' : "class_{$escapedName}_methods";
32883289
if ($this->type === "enum") {
32893290
$name = addslashes((string) $this->name);
32903291
$backingType = $this->enumBackingType
32913292
? $this->enumBackingType->toTypeCode() : "IS_UNDEF";
3292-
$code .= "\tzend_class_entry *class_entry = zend_register_internal_enum(\"$name\", $backingType, class_{$escapedName}_methods);\n";
3293+
$code .= "\tzend_class_entry *class_entry = zend_register_internal_enum(\"$name\", $backingType, $classMethods);\n";
32933294
if ($flags !== "") {
32943295
$code .= "\tclass_entry->ce_flags |= $flags\n";
32953296
}
@@ -3299,9 +3300,9 @@ public function getRegistration(array $allConstInfos): string
32993300
$className = $this->name->getLast();
33003301
$namespace = addslashes((string) $this->name->slice(0, -1));
33013302

3302-
$code .= "\tINIT_NS_CLASS_ENTRY(ce, \"$namespace\", \"$className\", class_{$escapedName}_methods);\n";
3303+
$code .= "\tINIT_NS_CLASS_ENTRY(ce, \"$namespace\", \"$className\", $classMethods);\n";
33033304
} else {
3304-
$code .= "\tINIT_CLASS_ENTRY(ce, \"$this->name\", class_{$escapedName}_methods);\n";
3305+
$code .= "\tINIT_CLASS_ENTRY(ce, \"$this->name\", $classMethods);\n";
33053306
}
33063307

33073308
if ($this->type === "class" || $this->type === "trait") {
@@ -5103,9 +5104,7 @@ static function (FuncInfo $funcInfo) use ($fileInfo, &$generatedFunctionDeclarat
51035104
}
51045105
);
51055106

5106-
if (!empty($fileInfo->funcInfos)) {
5107-
$code .= generateFunctionEntries(null, $fileInfo->funcInfos);
5108-
}
5107+
$code .= generateFunctionEntries(null, $fileInfo->funcInfos);
51095108

51105109
foreach ($fileInfo->classInfos as $classInfo) {
51115110
$code .= generateFunctionEntries($classInfo->name, $classInfo->funcInfos, $classInfo->cond);
@@ -5156,6 +5155,11 @@ function generateClassEntryCode(FileInfo $fileInfo, array $allConstInfos): strin
51565155

51575156
/** @param FuncInfo[] $funcInfos */
51585157
function generateFunctionEntries(?Name $className, array $funcInfos, ?string $cond = null): string {
5158+
// No need to add anything if there are no function entries
5159+
if ($funcInfos === []) {
5160+
return '';
5161+
}
5162+
51595163
$code = "\n";
51605164

51615165
if ($cond) {

‎ext/com_dotnet/com_extension_arginfo.h‎

Lines changed: 2 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎ext/curl/curl_arginfo.h‎

Lines changed: 3 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /