MaxSem has uploaded a new change for review.
https://gerrit.wikimedia.org/r/148523
Change subject: Fixes per CR on github
......................................................................
Fixes per CR on github
Change-Id: I3f3b9976db05695aab3b21f34f1886aa342f03c8
---
M fss.cpp
M test.sh
2 files changed, 11 insertions(+), 13 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/php/FastStringSearch
refs/changes/23/148523/1
diff --git a/fss.cpp b/fss.cpp
index 5df729d..df9a147 100644
--- a/fss.cpp
+++ b/fss.cpp
@@ -36,9 +36,8 @@
void close() {
int i;
for (i = 0; i < m_fss_r->replace_size; i++) {
- if (m_fss_r->replace[i]) {
- delete(m_fss_r->replace[i]);
- }
+ smart_delete(m_fss_r->replace[i]);
+ m_fss_r->replace[i] = NULL;
}
}
@@ -54,7 +53,7 @@
fss_resource_t * res;
const char *error;
- res = (fss_resource_t*)smart_malloc(sizeof(fss_resource_t));
+ res = smart_new<fss_resource_t>();
res->set = kwsalloc(NULL);
res->replace_size = 0;
@@ -106,9 +105,7 @@
return false;
}
- Array match = Array::Create();
- match.set( 0, (int64_t)(m.offset[0] + offset) );
- match.set( 1, (int64_t)(m.size[0]) );
+ Array match = make_packed_array((int64_t)(m.offset[0] + offset),
(int64_t)(m.size[0]));
return match;
}
@@ -118,7 +115,7 @@
const char *error;
int i = 0;
const char *string_key;
- uint string_key_len;
+ size_t string_key_len;
char buffer[40];
/* fss_resource_t has an open-ended array, we allocate enough memory
for the
@@ -128,6 +125,7 @@
res->replace_size = pairs.size();
for(ArrayIter iter(pairs); iter; ++iter) {
+ String s;
Variant key = iter.first();
/* Convert numeric keys to string */
if(key.getType() == KindOfInt64) {
@@ -135,8 +133,9 @@
string_key = buffer;
string_key_len = strlen(buffer);
} else {
- string_key = key.toString().c_str();
- string_key_len = key.toString().size();
+ s = key.toString();
+ string_key = s.c_str();
+ string_key_len = s.size();
}
/* Don't add zero-length strings, that will cause infinite
loops in
@@ -155,7 +154,7 @@
}
/* Add the value to the replace array */
- res->replace[i++] = new Variant(iter.second());
+ res->replace[i++] = smart_new<Variant>(iter.second());
}
kwsprep(res->set);
@@ -231,4 +230,3 @@
HHVM_GET_MODULE(fss)
} // namespace HPHP
-
diff --git a/test.sh b/test.sh
index 2195cd5..0af45dd 100644
--- a/test.sh
+++ b/test.sh
@@ -6,7 +6,7 @@
DIRNAME=`realpath ${DIRNAME}`
fi
-${HPHP_HOME}/hphp/hhvm/hhvm \
+hhvm \
-vDynamicExtensions.0=${DIRNAME}/fss.so \
${DIRNAME}/test.php
--
To view, visit https://gerrit.wikimedia.org/r/148523
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I3f3b9976db05695aab3b21f34f1886aa342f03c8
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/php/FastStringSearch
Gerrit-Branch: master
Gerrit-Owner: MaxSem <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits