diff options
author | Xinchen Hui <laruence@php.net> | 2014-10-30 16:55:40 +0800 |
---|---|---|
committer | Xinchen Hui <laruence@php.net> | 2014-10-30 16:55:40 +0800 |
commit | fced6e614811834d4edda6c0e4af9b769177ef2c (patch) | |
tree | abae486bd41f865d39e3c95142b0a6f99cc24867 | |
parent | af22cd665cbcbdfa07a3707d0651f719e023f0ec (diff) | |
download | php-git-fced6e614811834d4edda6c0e4af9b769177ef2c.tar.gz |
Save memory allocating
-rw-r--r-- | Zend/zend_vm_def.h | 8 | ||||
-rw-r--r-- | Zend/zend_vm_execute.h | 24 |
2 files changed, 20 insertions, 12 deletions
diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index 9f2d26a203..fad38c6428 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -3775,13 +3775,15 @@ ZEND_VM_HANDLER(99, ZEND_FETCH_CONSTANT, VAR|CONST|UNUSED, CONST) if ((opline->extended_value & IS_CONSTANT_UNQUALIFIED) != 0) { char *actual = (char *)zend_memrchr(Z_STRVAL_P(opline->op2.zv), '\\', Z_STRLEN_P(opline->op2.zv)); if (!actual) { - actual = Z_STRVAL_P(opline->op2.zv); + ZVAL_STR(EX_VAR(opline->result.var), zend_string_copy(Z_STR_P(opline->op2.zv))); } else { actual++; + ZVAL_STRINGL(EX_VAR(opline->result.var), + actual, Z_STRLEN_P(opline->op2.zv) - (actual - Z_STRVAL_P(opline->op2.zv))); } /* non-qualified constant - allow text substitution */ - zend_error(E_NOTICE, "Use of undefined constant %s - assumed '%s'", actual, actual); - ZVAL_STRINGL(EX_VAR(opline->result.var), actual, Z_STRLEN_P(opline->op2.zv)-(actual - Z_STRVAL_P(opline->op2.zv))); + zend_error(E_NOTICE, "Use of undefined constant %s - assumed '%s'", + Z_STRVAL_P(EX_VAR(opline->result.var)), Z_STRVAL_P(EX_VAR(opline->result.var))); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } else { diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 732c3f02a2..4f305c2258 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -4300,13 +4300,15 @@ static int ZEND_FASTCALL ZEND_FETCH_CONSTANT_SPEC_CONST_CONST_HANDLER(ZEND_OPCO if ((opline->extended_value & IS_CONSTANT_UNQUALIFIED) != 0) { char *actual = (char *)zend_memrchr(Z_STRVAL_P(opline->op2.zv), '\\', Z_STRLEN_P(opline->op2.zv)); if (!actual) { - actual = Z_STRVAL_P(opline->op2.zv); + ZVAL_STR(EX_VAR(opline->result.var), zend_string_copy(Z_STR_P(opline->op2.zv))); } else { actual++; + ZVAL_STRINGL(EX_VAR(opline->result.var), + actual, Z_STRLEN_P(opline->op2.zv) - (actual - Z_STRVAL_P(opline->op2.zv))); } /* non-qualified constant - allow text substitution */ - zend_error(E_NOTICE, "Use of undefined constant %s - assumed '%s'", actual, actual); - ZVAL_STRINGL(EX_VAR(opline->result.var), actual, Z_STRLEN_P(opline->op2.zv)-(actual - Z_STRVAL_P(opline->op2.zv))); + zend_error(E_NOTICE, "Use of undefined constant %s - assumed '%s'", + Z_STRVAL_P(EX_VAR(opline->result.var)), Z_STRVAL_P(EX_VAR(opline->result.var))); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } else { @@ -18950,13 +18952,15 @@ static int ZEND_FASTCALL ZEND_FETCH_CONSTANT_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE if ((opline->extended_value & IS_CONSTANT_UNQUALIFIED) != 0) { char *actual = (char *)zend_memrchr(Z_STRVAL_P(opline->op2.zv), '\\', Z_STRLEN_P(opline->op2.zv)); if (!actual) { - actual = Z_STRVAL_P(opline->op2.zv); + ZVAL_STR(EX_VAR(opline->result.var), zend_string_copy(Z_STR_P(opline->op2.zv))); } else { actual++; + ZVAL_STRINGL(EX_VAR(opline->result.var), + actual, Z_STRLEN_P(opline->op2.zv) - (actual - Z_STRVAL_P(opline->op2.zv))); } /* non-qualified constant - allow text substitution */ - zend_error(E_NOTICE, "Use of undefined constant %s - assumed '%s'", actual, actual); - ZVAL_STRINGL(EX_VAR(opline->result.var), actual, Z_STRLEN_P(opline->op2.zv)-(actual - Z_STRVAL_P(opline->op2.zv))); + zend_error(E_NOTICE, "Use of undefined constant %s - assumed '%s'", + Z_STRVAL_P(EX_VAR(opline->result.var)), Z_STRVAL_P(EX_VAR(opline->result.var))); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } else { @@ -28234,13 +28238,15 @@ static int ZEND_FASTCALL ZEND_FETCH_CONSTANT_SPEC_UNUSED_CONST_HANDLER(ZEND_OPC if ((opline->extended_value & IS_CONSTANT_UNQUALIFIED) != 0) { char *actual = (char *)zend_memrchr(Z_STRVAL_P(opline->op2.zv), '\\', Z_STRLEN_P(opline->op2.zv)); if (!actual) { - actual = Z_STRVAL_P(opline->op2.zv); + ZVAL_STR(EX_VAR(opline->result.var), zend_string_copy(Z_STR_P(opline->op2.zv))); } else { actual++; + ZVAL_STRINGL(EX_VAR(opline->result.var), + actual, Z_STRLEN_P(opline->op2.zv) - (actual - Z_STRVAL_P(opline->op2.zv))); } /* non-qualified constant - allow text substitution */ - zend_error(E_NOTICE, "Use of undefined constant %s - assumed '%s'", actual, actual); - ZVAL_STRINGL(EX_VAR(opline->result.var), actual, Z_STRLEN_P(opline->op2.zv)-(actual - Z_STRVAL_P(opline->op2.zv))); + zend_error(E_NOTICE, "Use of undefined constant %s - assumed '%s'", + Z_STRVAL_P(EX_VAR(opline->result.var)), Z_STRVAL_P(EX_VAR(opline->result.var))); CHECK_EXCEPTION(); ZEND_VM_NEXT_OPCODE(); } else { |