Changeset 271 for trunk/ext/php
- Timestamp:
- 08/09/2007 05:41:29 (16 months ago)
- Files:
-
- 1 modified
-
trunk/ext/php/phpext.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ext/php/phpext.c
r268 r271 455 455 456 456 case IS_STRING: 457 syck_emit_scalar(e, "str", scalar_ none, 0, 0, 0, Z_STRVAL_P(data), Z_STRLEN_P(data));457 syck_emit_scalar(e, "str", scalar_2quote, 0, 0, 0, Z_STRVAL_P(data), Z_STRLEN_P(data)); 458 458 break; 459 459 … … 461 461 { 462 462 HashTable *tbl = Z_ARRVAL_P(data); 463 int flat_and_short = false; 464 465 /* we try to detect if array is short and flat */ 466 if (tbl->nNumOfElements <= 6) { 467 flat_and_short = true; 468 469 for (zend_hash_internal_pointer_reset(tbl); zend_hash_has_more_elements(tbl) == SUCCESS; zend_hash_move_forward(tbl)) { 470 zval **ppzval; 471 472 zend_hash_get_current_data(tbl, (void **)&ppzval); 473 474 if (Z_TYPE_P(*ppzval) == IS_ARRAY || Z_TYPE_P(*ppzval) == IS_OBJECT) { 475 flat_and_short = false; 476 } 477 } 478 } 463 479 464 480 if (zend_hash_index_exists(tbl, 0)) { 465 481 /* indexed array */ 466 syck_emit_seq(e, "table", seq_none); 482 if (flat_and_short) 483 syck_emit_seq(e, "table", seq_inline); 484 else 485 syck_emit_seq(e, "table", seq_none); 467 486 468 487 for (zend_hash_internal_pointer_reset(tbl); zend_hash_has_more_elements(tbl) == SUCCESS; zend_hash_move_forward(tbl)) { … … 479 498 } else { 480 499 /* associative array */ 481 syck_emit_map(e, "table", map_none); 500 if (flat_and_short) 501 syck_emit_map(e, "table", map_inline); 502 else 503 syck_emit_map(e, "table", map_none); 482 504 483 505 for (zend_hash_internal_pointer_reset(tbl); zend_hash_has_more_elements(tbl) == SUCCESS; zend_hash_move_forward(tbl)) {