Commit 3864be81 authored by Frederick Zhang's avatar Frederick Zhang

less copy while parsing

parent 30a05202
Pipeline #342 passed with stage
in 45 seconds
......@@ -27,10 +27,9 @@ size_t bint::length() const {
zval * bint::parse(const std::string &ben, size_t &pt) {
if (ben[pt] != 'i')
return bitem::throw_general_exception("Error parsing bint");
++pt;
std::string strint = "";
while (ben[pt] != 'e') strint += ben[pt++];
long result = std::stoll(strint);
size_t start = ++pt;
while (ben[pt] != 'e') ++pt;
long result = std::stoll(ben.substr(start, pt - start));
++pt;
zval *zv = new zval();
......
......@@ -28,15 +28,15 @@ zval * bstr::parse(const std::string &ben, size_t &pt) {
return bitem::throw_general_exception("Error parsing bstr");
const size_t start = pt;
while (isdigit(ben[pt])) ++pt;
std::string len = ben.substr(start, pt - start);
size_t len = std::stoull(ben.substr(start, pt - start));
++pt;
zval *zv = new zval();
zend_object *zo = zend_container::bstr_object_new(zend_container::bstr_ce);
ZVAL_OBJ(zv, zo);
bstr_object *intern = zend_container::bstr_fetch_object(Z_OBJ_P(zv));
intern->bstr_data = new bstr(ben.substr(pt, std::stoull(len)));
pt += std::stoull(len);
intern->bstr_data = new bstr(ben.substr(pt, len));
pt += len;
return zv;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment