php-i18n Digest 26 Mar 2006 11:45:15 -0000 Issue 322

Topics (messages 992 through 993):

Re: Hash api change
        992 by: Andi Gutmans

Re: php-src /ext/standard array.c php_array.h  /ext/unicode collator.c 
config.m4 config.w32 php_unicode.h unicode.c
        993 by: l0t3k

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [email protected]


----------------------------------------------------------------------
--- Begin Message --- OK I misunderstood then. I thought your proposal means that zend_hash_key == HashKey. How would they be different, or is there some info which one would have and the other not?

Andi

At 11:01 AM 3/16/2006, Marcus Boerger wrote:
Hello Andrei,

  we need it right now becuase of the current layout. And imo that's a
design flaw which is why i brought it up here with an option on how to
change it after discussing it. Having two different layouts allows us
to not need to a pointer to the key string plus eventually allocate
memory twice. But this also forces us to copy the key struct in the
apply func that gives access to the key for every element.

If we have the layout proposed by me we could also provide an apply
version that easily gives access to the element, the key and a parameter.
Having to use the following to access the key, made most cases do the
iteration inplace. Just because the following is pretty slow for two
reasons. First va_args stuff is potentially slow an some machines and
second having to allocate a tsrm key on some machines is especially slow.

typedef int (*apply_func_args_t)(void *pDest, int num_args, va_list args, zend_hash_key *hash_key); ZEND_API void zend_hash_apply_with_arguments(HashTable *ht, apply_func_args_t apply_func, int, ...);

Since normally a struct can be used very easily and efficient, where
multiple arguments would be used otherwise. The next layout would
imo be a nice addition:

typedef int (*apply_func_key_t)(void *pDest, zend_hash_key *hash_key, void *argument TSRMLS_DC); ZEND_API void zend_hash_apply_with_key(HashTable *ht, apply_func_key_t apply_func, void *argument TSRMLS_DC);

This design change suggestion of course goes especially to Andi/Zeev.

marcus

Thursday, March 16, 2006, 7:11:39 AM, you wrote:

> On Mar 11, 2006, at 4:22 AM, Marcus Boerger wrote:

> [snip]

>> So now HashKey matches zend_hash_key just by pure reordering.

> Why do we need both HashKey and zend_hash_key?

> -Andrei




--
Best regards,
 marcus

--- End Message ---
--- Begin Message ---
Derick,
  i know this is the initial dump, but have a look also here :

http://icu.sourceforge.net/userguide/Collate_ServiceArchitecture.html#Sort_Key

For small lists the current implementation is OK, but after a threshold, 
sort keys are better performance-wise.

Here's an implementation of mine (untested, unfortunately) which attempts to 
use sort-keys as well as accomodating iterators (search for "sort").
Never mind the use of the C++ API, the concept is the same.

http://cvs.iworks.at/co.php/php-i18n/collator.cpp?r=1.3

I actually have a different implementation (strictly C) which switches 
between ucol_compare and sort-key generation after a threshold,
but i havent had time to work on it.

l0t3k

""Derick Rethans"" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> derick Sun Mar 26 11:06:24 2006 UTC
>
>  Added files:
>    /php-src/ext/unicode collator.c
>
>  Modified files:
>    /php-src/ext/standard array.c php_array.h
>    /php-src/ext/unicode config.m4 config.w32 php_unicode.h unicode.c
>  Log:
>  - Implemented basic collation support. For some reason "new Collator" 
> gives segfaults when the object's collation resource is used.
>  - The following example shows what is implemented:
>
>  <?php
>  $orig = $strings = array(
>      'côte',
>      'cote',
>      'côté',
>      'coté',
>      'fluÃYe',
>      'flüÃYe',
>  );
>
>  echo "German phonebook:\n";
>  $c = collator_create( "[EMAIL PROTECTED]" );
>  foreach($c->sort($strings) as $string) {
>      echo $string, "\n";
>  }
>  echo $c->getAttribute(Collator::FRENCH_COLLATION) == Collator::ON
>      ? "With" : "Without", " french accent sorting order\n";
>
>  echo "\nFrench with options:\n";
>  $c = collator_create( "fr" );
>  $c->setAttribute(Collator::CASE_FIRST, Collator::UPPER_FIRST);
>  $c->setAttribute(Collator::CASE_LEVEL, Collator::ON);
>  $c->setStrength(Collator::SECONDARY);
>  foreach($c->sort($strings) as $string) {
>      echo $string, "\n";
>  }
>  echo $c->getAttribute(Collator::FRENCH_COLLATION) == Collator::ON
>      ? "With" : "Without", " french accent sorting order\n";
>  ?>
>
> 

--- End Message ---

Reply via email to