com php-src: Make ast->children a uint: Zend/zend_ast.c Z end/zend_ast.h Zend/zend_compile.h
| From: | Nikita Popov | Date: | Thu, 19 Jun 2014 11:48:50 +0000 |
| Subject: | com php-src: Make ast->children a uint: Zend/zend_ast.c Z end/zend_ast.h Zend/zend_compile.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-81052@lists.php.net to get a copy of this message | ||
Commit: 89ecd73a0402a4a0f6bfcf579177b8b3e91b4dc6
Author: Nikita Popov <nikic@php.net> Thu, 19 Jun 2014 13:08:21 +0200
Parents: 0c81b3eae26bf41fa49b4c3ca538494c2856e3b8
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=89ecd73a0402a4a0f6bfcf579177b8b3e91b4dc6
Log:
Make ast->children a uint
Future optimization: only use uint for dynamic lists and use a
uchar or even an introspection function to get the child count.
Changed paths:
M Zend/zend_ast.c
M Zend/zend_ast.h
M Zend/zend_compile.h
Diff:
diff --git a/Zend/zend_ast.c b/Zend/zend_ast.c
index ba0b57f..9a79559 100644
--- a/Zend/zend_ast.c
+++ b/Zend/zend_ast.c
@@ -27,7 +27,7 @@ ZEND_API zend_ast *zend_ast_create_constant(zval *zv)
{
zend_ast_zval *ast = emalloc(sizeof(zend_ast_zval));
ast->kind = ZEND_CONST;
- ast->children = 0;
+ ast->EA = 0;
ZVAL_COPY_VALUE(&ast->val, zv);
return (zend_ast *) ast;
}
@@ -36,7 +36,7 @@ ZEND_API zend_ast *zend_ast_create_znode(znode *node)
{
zend_ast_znode *ast = emalloc(sizeof(zend_ast_znode));
ast->kind = ZEND_AST_ZNODE;
- ast->children = 0;
+ ast->EA = 0;
ast->node = *node;
return (zend_ast *) ast;
}
@@ -45,6 +45,7 @@ ZEND_API zend_ast* zend_ast_create_unary(uint kind, zend_ast *op0)
{
zend_ast *ast = emalloc(sizeof(zend_ast));
ast->kind = kind;
+ ast->EA = 0;
ast->children = 1;
ast->child[0] = op0;
return ast;
@@ -54,6 +55,7 @@ ZEND_API zend_ast* zend_ast_create_binary(uint kind, zend_ast *op0, zend_ast *op
{
zend_ast *ast = emalloc(sizeof(zend_ast) + sizeof(zend_ast *));
ast->kind = kind;
+ ast->EA = 0;
ast->children = 2;
ast->child[0] = op0;
ast->child[1] = op1;
@@ -64,6 +66,7 @@ ZEND_API zend_ast* zend_ast_create_ternary(uint kind, zend_ast *op0, zend_ast *o
{
zend_ast *ast = emalloc(sizeof(zend_ast) + sizeof(zend_ast *) * 2);
ast->kind = kind;
+ ast->EA = 0;
ast->children = 3;
ast->child[0] = op0;
ast->child[1] = op1;
@@ -76,6 +79,7 @@ ZEND_API zend_ast *zend_ast_create_dynamic(uint kind)
/* use 4 children as default */
zend_ast *ast = emalloc(sizeof(zend_ast) + sizeof(zend_ast *) * 3);
ast->kind = kind;
+ ast->EA = 0;
ast->children = 0;
return ast;
}
@@ -396,7 +400,7 @@ ZEND_API void zend_ast_destroy(zend_ast *ast)
if (ast->kind == ZEND_CONST) {
zval_dtor(zend_ast_get_zval(ast));
- } else {
+ } else if (ast->kind != ZEND_AST_ZNODE) {
for (i = 0; i < ast->children; i++) {
if (ast->child[i]) {
zend_ast_destroy(ast->child[i]);
diff --git a/Zend/zend_ast.h b/Zend/zend_ast.h
index c89b82c..cceb3b0 100644
--- a/Zend/zend_ast.h
+++ b/Zend/zend_ast.h
@@ -75,13 +75,14 @@ typedef enum _zend_ast_kind {
struct _zend_ast {
unsigned short kind;
- unsigned short children;
+ unsigned short EA;
+ zend_uint children;
zend_ast *child[1];
};
typedef struct _zend_ast_zval {
unsigned short kind;
- unsigned short children;
+ unsigned short EA;
zval val;
} zend_ast_zval;
diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h
index bbf2bc7..6dfa74f 100644
--- a/Zend/zend_compile.h
+++ b/Zend/zend_compile.h
@@ -90,7 +90,7 @@ typedef struct _znode { /* used only during compilation */
/* Temporarily defined here, to avoid header ordering issues */
typedef struct _zend_ast_znode {
unsigned short kind;
- unsigned short children;
+ unsigned short EA;
znode node;
} zend_ast_znode;
ZEND_API zend_ast *zend_ast_create_znode(znode *node);