Commit:    e3d625bc4ef1f66a9c8f82d3d188ea71c783b65f
Author:    Stanislav Malyshev <s...@php.net>         Sun, 23 Jun 2013 23:52:28 
-0700
Parents:   8aba119f5525663ab202e459929d7fb3271aef51
Branches:  PHP-5.4 PHP-5.5 master

Link:       
http://git.php.net/?p=php-src.git;a=commitdiff;h=e3d625bc4ef1f66a9c8f82d3d188ea71c783b65f

Log:
small optimization

Changed paths:
  M  ext/intl/grapheme/grapheme_util.c
  M  ext/intl/grapheme/grapheme_util.h


Diff:
diff --git a/ext/intl/grapheme/grapheme_util.c 
b/ext/intl/grapheme/grapheme_util.c
index 595f0cc..883fa03 100644
--- a/ext/intl/grapheme/grapheme_util.c
+++ b/ext/intl/grapheme/grapheme_util.c
@@ -155,6 +155,9 @@ int grapheme_strpos_utf16(unsigned char *haystack, int32_t 
haystack_len, unsigne
        status = U_ZERO_ERROR;
        bi = grapheme_get_break_iterator(u_break_iterator_buffer, &status 
TSRMLS_CC );
        STRPOS_CHECK_STATUS(status, "Failed to get iterator");
+       status = U_ZERO_ERROR;
+       ubrk_setText(bi, uhaystack, uhaystack_len, &status);
+       STRPOS_CHECK_STATUS(status, "Failed to set up iterator");
 
        status = U_ZERO_ERROR;
        src = usearch_open(uneedle, uneedle_len, uhaystack, uhaystack_len, "", 
bi, &status);
@@ -169,7 +172,7 @@ int grapheme_strpos_utf16(unsigned char *haystack, int32_t 
haystack_len, unsigne
        }
 
        if(offset != 0) {
-               offset_pos = grapheme_get_haystack_offset(bi, uhaystack, 
uhaystack_len, offset);
+               offset_pos = grapheme_get_haystack_offset(bi, offset);
                if(offset_pos == -1) {
                        status = U_ILLEGAL_ARGUMENT_ERROR;
                        STRPOS_CHECK_STATUS(status, "Invalid search offset");   
@@ -191,7 +194,7 @@ int grapheme_strpos_utf16(unsigned char *haystack, int32_t 
haystack_len, unsigne
        }
        STRPOS_CHECK_STATUS(status, "Error looking up string");
        if(char_pos != USEARCH_DONE && ubrk_isBoundary(bi, char_pos)) {
-               ret_pos = grapheme_count_graphemes(bi, uhaystack, char_pos);
+               ret_pos = grapheme_count_graphemes(bi, uhaystack,char_pos);
                if(puchar_pos) {
                        *puchar_pos = char_pos;
                }
@@ -290,18 +293,12 @@ int32_t grapheme_count_graphemes(UBreakIterator *bi, 
UChar *string, int32_t stri
 
 
 /* {{{         grapheme_get_haystack_offset - bump the haystack pointer based 
on the grapheme count offset */
-int grapheme_get_haystack_offset(UBreakIterator* bi, UChar *uhaystack, int32_t 
uhaystack_len, int32_t offset)
+int grapheme_get_haystack_offset(UBreakIterator* bi, int32_t offset)
 {
-       UErrorCode              status;
        int32_t pos;
        int32_t (*iter_op)(UBreakIterator* bi);
        int iter_incr;
 
-       if ( NULL != bi ) {
-               status = U_ZERO_ERROR;
-               ubrk_setText (bi, uhaystack, uhaystack_len, &status);
-       }
-
        if ( 0 == offset ) {
                return 0;
        }
diff --git a/ext/intl/grapheme/grapheme_util.h 
b/ext/intl/grapheme/grapheme_util.h
index a2a1bc8..14f3f22 100644
--- a/ext/intl/grapheme/grapheme_util.h
+++ b/ext/intl/grapheme/grapheme_util.h
@@ -37,7 +37,7 @@ int32_t grapheme_count_graphemes(UBreakIterator *bi, UChar 
*string, int32_t stri
 
 inline void *grapheme_memrchr_grapheme(const void *s, int c, int32_t n);
 
-int grapheme_get_haystack_offset(UBreakIterator* bi, UChar *uhaystack, int32_t 
uhaystack_len, int32_t offset);
+int grapheme_get_haystack_offset(UBreakIterator* bi, int32_t offset);
 
 int32_t grapheme_strrpos_ascii(unsigned char *haystack, int32_t haystack_len, 
unsigned char *needle, int32_t needle_len, int32_t offset);


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to