8000 Apply changes from PR #924 · jrtkcoder/phpredis@a86914f · GitHub
[go: up one dir, main page]

Skip to content

Commit a86914f

Browse files
committed
Apply changes from PR phpredis#924
1 parent e64bd72 commit a86914f

File tree

3 files changed

+9
-29
lines changed

3 files changed

+9
-29
lines changed

redis_array_impl.c

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -411,16 +411,11 @@ ra_extract_key(RedisArray *ra, const char *key, int key_len, int *out_len TSRMLS
411411
char *start, *end;
412412
*out_len = key_len;
413413

414-
if(Z_TYPE(ra->z_fun) != IS_UNDEF)
414+
if (Z_TYPE(ra->z_fun) != IS_UNDEF) {
415415
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+
}
424419

425420
/* found substring */
426421
*out_len = end - start - 1;
@@ -743,17 +738,6 @@ ra_rehash_scan(zval *z_redis, char ***keys, int **key_lens, const char *cmd, con
743738
return count;
744739
}
745740

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-
757741
/* run TYPE to find the type */
758742
static zend_bool
759743
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
12121196

12131197
/* list all keys */
12141198
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);
12161200
} 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);
12181202
}
12191203

12201204
/* callback */
@@ -1231,12 +1215,10 @@ ra_rehash_server(RedisArray *ra, zval *z_redis, const char *hostname, zend_bool
12311215
if(strcmp(hostname, ra->hosts[target_pos] 8000 )) { /* different host */
12321216
ra_move_key(keys[i], key_lens[i], z_redis, z_target TSRMLS_CC);
12331217
}
1234-
}
1235-
1236-
/* cleanup */
1237-
for(i = 0; i < count; ++i) {
1218+
/* cleanup */
12381219
efree(keys[i]);
12391220
}
1221+
12401222
efree(keys);
12411223
efree(key_lens);
12421224
}

redis_commands.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3250,4 +3250,4 @@ void redis_unserialize_handler(INTERNAL_FUNCTION_PARAMETERS,
32503250
}
32513251
}
32523252

3253-
/* vim: set tabstop=4 softtabstop=4 noexpandtab shiftwidth=4: */
3253+
/* vim: set tabstop=4 softtabstop=4 expandtab shiftwidth=4: */

redis_session.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
+----------------------------------------------------------------------+
2121
*/
2222

23-
#include "common.h"
24-
2523
#ifdef HAVE_CONFIG_H
2624
#include "config.h"
2725
#endif

0 commit comments

Comments
 (0)
0