@@ -411,16 +411,11 @@ ra_extract_key(RedisArray *ra, const char *key, int key_len, int *out_len TSRMLS
411
411
char * start , * end ;
412
412
* out_len = key_len ;
413
413
414
- if (Z_TYPE (ra -> z_fun ) != IS_UNDEF )
414
+ if (Z_TYPE (ra -> z_fun ) != IS_UNDEF ) {
415
415
return ra_call_extractor (ra , key , key_len , out_len TSRMLS_CC );
416
-
417
- /* look for '{' */
418
- start = strchr (key , '{' );
419
- if (!start ) return estrndup (key , key_len );
420
-
421
- /* look for '}' */
422
- end = strchr (start + 1 , '}' );
423
- if (!end ) return estrndup (key , key_len );
416
+ } else if ((start = strchr (key , '{' )) == NULL || (end = strchr (start + 1 , '}' )) == NULL ) {
417
+ return estrndup (key , key_len );
418
+ }
424
419
425
420
/* found substring */
426
421
* out_len = end - start - 1 ;
@@ -743,17 +738,6 @@ ra_rehash_scan(zval *z_redis, char ***keys, int **key_lens, const char *cmd, con
743
738
return count ;
744
739
}
745
740
746
- static long
747
- ra_rehash_scan_index (zval * z_redis , char * * * keys , int * * key_lens TSRMLS_DC ) {
748
- return ra_rehash_scan (z_redis , keys , key_lens , "SMEMBERS" , PHPREDIS_INDEX_NAME TSRMLS_CC );
749
- }
750
-
751
- /* list keys using KEYS command */
752
- static long
753
- ra_rehash_scan_keys (zval * z_redis , char * * * keys , int * * key_lens TSRMLS_DC ) {
754
- return ra_rehash_scan (z_redis , keys , key_lens , "KEYS" , "*" TSRMLS_CC );
755
- }
756
-
757
741
/* run TYPE to find the type */
758
742
static zend_bool
759
743
ra_get_key_type (zval * z_redis , const char * key , int key_len , zval * z_from , long * res TSRMLS_DC ) {
@@ -1212,9 +1196,9 @@ ra_rehash_server(RedisArray *ra, zval *z_redis, const char *hostname, zend_bool
1212
1196
1213
1197
/* list all keys */
1214
1198
if (b_index ) {
1215
- count = ra_rehash_scan_index (z_redis , & keys , & key_lens TSRMLS_CC );
1199
+ count = ra_rehash_scan (z_redis , & keys , & key_lens , "SMEMBERS" , PHPREDIS_INDEX_NAME TSRMLS_CC );
1216
1200
} else {
1217
- count = ra_rehash_scan_keys (z_redis , & keys , & key_lens TSRMLS_CC );
1201
+ count = ra_rehash_scan (z_redis , & keys , & key_lens , "KEYS" , "*" TSRMLS_CC );
1218
1202
}
1219
1203
1220
1204
/* callback */
@@ -1231,12 +1215,10 @@ ra_rehash_server(RedisArray *ra, zval *z_redis, const char *hostname, zend_bool
1231
1215
if (strcmp (hostname , ra -> hosts [target_pos ]
8000
)) { /* different host */
1232
1216
ra_move_key (keys [i ], key_lens [i ], z_redis , z_target TSRMLS_CC );
1233
1217
}
1234
- }
1235
-
1236
- /* cleanup */
1237
- for (i = 0 ; i < count ; ++ i ) {
1218
+ /* cleanup */
1238
1219
efree (keys [i ]);
1239
1220
}
1221
+
1240
1222
efree (keys );
1241
1223
efree (key_lens );
1242
1224
}
0 commit comments