cvs: ZendEngine2 / zend_compile.c
| From: | Zeev Suraski | Date: | Wed, 28 Jan 2004 09:13:43 +0000 |
| Subject: | cvs: ZendEngine2 / zend_compile.c | ||
| Groups: | php.zend-engine.cvs | ||
| Request: | Send a blank email to php-zend-engine-cvs+get-2287@lists.php.net to get a copy of this message | ||
zeev Wed Jan 28 04:13:43 2004 EDT
Modified files:
/ZendEngine2 zend_compile.c
Log:
Code relayout
http://cvs.php.net/diff.php/ZendEngine2/zend_compile.c?r1=1.518&r2=1.519&ty=u
Index: ZendEngine2/zend_compile.c
diff -u ZendEngine2/zend_compile.c:1.518 ZendEngine2/zend_compile.c:1.519
--- ZendEngine2/zend_compile.c:1.518 Sat Jan 24 11:59:24 2004
+++ ZendEngine2/zend_compile.c Wed Jan 28 04:13:41 2004
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_compile.c,v 1.518 2004/01/24 16:59:24 helly Exp $ */
+/* $Id: zend_compile.c,v 1.519 2004/01/28 09:13:41 zeev Exp $ */
#include "zend_language_parser.h"
#include "zend.h"
@@ -1847,6 +1847,7 @@
}
+
static inline void do_implement_interface(zend_class_entry *ce, zend_class_entry *iface TSRMLS_DC)
{
if (!(ce->ce_flags & ZEND_ACC_INTERFACE) && iface->interface_gets_implemented
&& iface->interface_gets_implemented(iface, ce TSRMLS_CC) == FAILURE) {
@@ -1861,32 +1862,34 @@
int i, ce_num, if_num = iface->num_interfaces;
zend_class_entry *entry;
- if (if_num) {
- ce_num = ce->num_interfaces;
- if (ce->type == ZEND_INTERNAL_CLASS) {
- ce->interfaces = (zend_class_entry **) realloc(ce->interfaces, sizeof(zend_class_entry *)
* (ce_num + if_num));
- } else {
- ce->interfaces = (zend_class_entry **) erealloc(ce->interfaces, sizeof(zend_class_entry *)
* (ce_num + if_num));
- }
+ if (if_num==0) {
+ return;
+ }
+ ce_num = ce->num_interfaces;
- /* only have every interface ones - this holds for the list we append too, what makes the test a
bit faster */
- while (if_num--) {
- entry = iface->interfaces[if_num];
- for (i = 0; i < ce_num; ++i) {
- if (ce->interfaces[i] == entry) {
- break;
- }
- }
- if (i == ce_num) {
- ce->interfaces[ce->num_interfaces++] = entry;
+ if (ce->type == ZEND_INTERNAL_CLASS) {
+ ce->interfaces = (zend_class_entry **) realloc(ce->interfaces, sizeof(zend_class_entry *) *
(ce_num + if_num));
+ } else {
+ ce->interfaces = (zend_class_entry **) erealloc(ce->interfaces, sizeof(zend_class_entry *)
* (ce_num + if_num));
+ }
+
+ /* Inherit the interfaces, only if they're not already inherited by the class */
+ while (if_num--) {
+ entry = iface->interfaces[if_num];
+ for (i = 0; i < ce_num; i++) {
+ if (ce->interfaces[i] == entry) {
+ break;
}
}
-
- /* and now call the implementing handlers */
- while (ce_num < ce->num_interfaces) {
- do_implement_interface(ce, ce->interfaces[ce_num++] TSRMLS_CC);
+ if (i == ce_num) {
+ ce->interfaces[ce->num_interfaces++] = entry;
}
}
+
+ /* and now call the implementing handlers */
+ while (ce_num < ce->num_interfaces) {
+ do_implement_interface(ce, ce->interfaces[ce_num++] TSRMLS_CC);
+ }
}