Stop constructing Strings for o_invoke.
Grepping around for string literals passed to o_invoke turned up these suspects. It's not a great practice. The only one that might matter to perf is the "count" invocation in ext_array.
Esse commit está contido em:
@@ -21,15 +21,19 @@
|
||||
#include <runtime/base/builtin_functions.h>
|
||||
|
||||
namespace HPHP {
|
||||
|
||||
static StaticString s_read("read");
|
||||
static StaticString s_write("write");
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
String PhpThriftBuffer::readImpl() {
|
||||
Array args(CREATE_VECTOR1(m_size));
|
||||
return m_xin->o_invoke("read", args, -1);
|
||||
return m_xin->o_invoke(s_read, args, -1);
|
||||
}
|
||||
|
||||
void PhpThriftBuffer::flushImpl(CStrRef data) {
|
||||
m_xout->o_invoke("write", CREATE_VECTOR1(data), -1);
|
||||
m_xout->o_invoke(s_write, CREATE_VECTOR1(data), -1);
|
||||
}
|
||||
|
||||
void PhpThriftBuffer::throwError(const char *msg, int code) {
|
||||
|
||||
@@ -18,6 +18,12 @@
|
||||
#include <runtime/ext/ext_debugger.h>
|
||||
|
||||
namespace HPHP { namespace Eval {
|
||||
|
||||
static StaticString s_onAutoComplete("onAutoComplete");
|
||||
static StaticString s_help("help");
|
||||
static StaticString s_onClient("onClient");
|
||||
static StaticString s_onServer("onServer");
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void CmdUser::sendImpl(DebuggerThriftBuffer &thrift) {
|
||||
@@ -74,7 +80,7 @@ void CmdUser::invokeList(DebuggerClient *client, const std::string &cls) {
|
||||
pclient->m_client = client;
|
||||
try {
|
||||
Object cmd = create_object(cls.c_str(), null_array);
|
||||
cmd->o_invoke("onAutoComplete", CREATE_VECTOR1(pclient), -1);
|
||||
cmd->o_invoke(s_onAutoComplete, CREATE_VECTOR1(pclient), -1);
|
||||
} catch (...) {}
|
||||
}
|
||||
|
||||
@@ -83,7 +89,7 @@ bool CmdUser::invokeHelp(DebuggerClient *client, const std::string &cls) {
|
||||
pclient->m_client = client;
|
||||
try {
|
||||
Object cmd = create_object(cls.c_str(), null_array);
|
||||
Variant ret = cmd->o_invoke("help", CREATE_VECTOR1(pclient), -1);
|
||||
Variant ret = cmd->o_invoke(s_help, CREATE_VECTOR1(pclient), -1);
|
||||
return !same(ret, false);
|
||||
} catch (...) {}
|
||||
return false;
|
||||
@@ -94,7 +100,7 @@ bool CmdUser::invokeClient(DebuggerClient *client, const std::string &cls) {
|
||||
pclient->m_client = client;
|
||||
try {
|
||||
Object cmd = create_object(cls.c_str(), null_array);
|
||||
Variant ret = cmd->o_invoke("onClient", CREATE_VECTOR1(pclient), -1);
|
||||
Variant ret = cmd->o_invoke(s_onClient, CREATE_VECTOR1(pclient), -1);
|
||||
return !same(ret, false);
|
||||
} catch (...) {}
|
||||
return false;
|
||||
@@ -105,7 +111,7 @@ bool CmdUser::onServer(DebuggerProxy *proxy) {
|
||||
p_DebuggerProxyCmdUser pproxy(NEWOBJ(c_DebuggerProxyCmdUser)());
|
||||
pproxy->m_proxy = proxy;
|
||||
try {
|
||||
Variant ret = m_cmd->o_invoke("onServer", CREATE_VECTOR1(pproxy), -1);
|
||||
Variant ret = m_cmd->o_invoke(s_onServer, CREATE_VECTOR1(pproxy), -1);
|
||||
return !same(ret, false);
|
||||
} catch (...) {}
|
||||
return false;
|
||||
|
||||
@@ -31,10 +31,17 @@
|
||||
|
||||
#define SORT_DESC 3
|
||||
#define SORT_ASC 4
|
||||
|
||||
namespace HPHP {
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static StaticString s_Iterator("Iterator");
|
||||
static StaticString s_IteratorAggregate("IteratorAggregate");
|
||||
static StaticString s_ArrayIterator("ArrayIterator");
|
||||
static StaticString s_MutableArrayIterator("MutableArrayIterator");
|
||||
|
||||
static StaticString s_getIterator("getIterator");
|
||||
static StaticString s_count("count");
|
||||
|
||||
const int64_t k_UCOL_DEFAULT = UCOL_DEFAULT;
|
||||
|
||||
const int64_t k_UCOL_PRIMARY = UCOL_PRIMARY;
|
||||
@@ -603,7 +610,7 @@ int64_t f_count(CVarRef var, bool recursive /* = false */) {
|
||||
{
|
||||
Object obj = var.toObject();
|
||||
if (obj.instanceof(SystemLib::s_CountableClass)) {
|
||||
return obj->o_invoke("count", null_array, -1);
|
||||
return obj->o_invoke(s_count, null_array, -1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -655,13 +662,6 @@ Variant f_key(VRefParam array) {
|
||||
}
|
||||
|
||||
|
||||
static StaticString s_Iterator("Iterator");
|
||||
static StaticString s_IteratorAggregate("IteratorAggregate");
|
||||
static StaticString s_ArrayIterator("ArrayIterator");
|
||||
static StaticString s_MutableArrayIterator("MutableArrayIterator");
|
||||
|
||||
static StaticString s_getIterator("getIterator");
|
||||
|
||||
static Variant f_hphp_get_iterator(VRefParam iterable, bool isMutable) {
|
||||
if (iterable.isArray()) {
|
||||
if (isMutable) {
|
||||
|
||||
@@ -33,6 +33,8 @@
|
||||
#include <system/lib/systemlib.h>
|
||||
|
||||
namespace HPHP {
|
||||
|
||||
static StaticString s___dorequest("__dorequest");
|
||||
IMPLEMENT_DEFAULT_EXTENSION(soap);
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// helper classes for setting/resetting globals within a method call
|
||||
@@ -473,7 +475,7 @@ static bool do_request(c_SoapClient *client, xmlDoc *request,
|
||||
if (client->m_trace) {
|
||||
client->m_last_request = String((char*)buf, buf_size, CopyString);
|
||||
}
|
||||
response = client->o_invoke_few_args("__dorequest", -1, 5,
|
||||
response = client->o_invoke_few_args(s___dorequest, -1, 5,
|
||||
String(buf, buf_size, AttachLiteral),
|
||||
String(location, AttachLiteral),
|
||||
String(action, AttachLiteral),
|
||||
|
||||
@@ -28,6 +28,12 @@ static StaticString s_spl_autoload("spl_autoload");
|
||||
static StaticString s_spl_autoload_call("spl_autoload_call");
|
||||
static StaticString s_default_extensions(".inc,.php");
|
||||
|
||||
static StaticString s_rewind("rewind");
|
||||
static StaticString s_valid("valid");
|
||||
static StaticString s_next("next");
|
||||
static StaticString s_current("current");
|
||||
static StaticString s_key("key");
|
||||
|
||||
#define SPL_ADD_CLASS(cls) ret.set(#cls, #cls)
|
||||
|
||||
Array f_spl_classes() {
|
||||
@@ -214,14 +220,14 @@ Variant f_iterator_apply(CVarRef obj, CVarRef func,
|
||||
return false;
|
||||
}
|
||||
Object pobj = obj.toObject();
|
||||
pobj->o_invoke("rewind", null_array, -1);
|
||||
pobj->o_invoke(s_rewind, null_array, -1);
|
||||
int64_t count = 0;
|
||||
while (same(pobj->o_invoke("valid", null_array, -1), true)) {
|
||||
while (same(pobj->o_invoke(s_valid, null_array, -1), true)) {
|
||||
if (!same(vm_call_user_func(func, params), true)) {
|
||||
break;
|
||||
}
|
||||
++count;
|
||||
pobj->o_invoke("next", null_array, -1);
|
||||
pobj->o_invoke(s_next, null_array, -1);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
@@ -231,11 +237,11 @@ Variant f_iterator_count(CVarRef obj) {
|
||||
return false;
|
||||
}
|
||||
Object pobj = obj.toObject();
|
||||
pobj->o_invoke("rewind", null_array, -1);
|
||||
pobj->o_invoke(s_rewind, null_array, -1);
|
||||
int64_t count = 0;
|
||||
while (same(pobj->o_invoke("valid", null_array, -1), true)) {
|
||||
while (same(pobj->o_invoke(s_valid, null_array, -1), true)) {
|
||||
++count;
|
||||
pobj->o_invoke("next", null_array, -1);
|
||||
pobj->o_invoke(s_next, null_array, -1);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
@@ -246,16 +252,16 @@ Variant f_iterator_to_array(CVarRef obj, bool use_keys /* = true */) {
|
||||
}
|
||||
Array ret(Array::Create());
|
||||
Object pobj = obj.toObject();
|
||||
pobj->o_invoke("rewind", null_array, -1);
|
||||
while (same(pobj->o_invoke("valid", null_array, -1), true)) {
|
||||
Variant val = pobj->o_invoke("current", null_array, -1);
|
||||
pobj->o_invoke(s_rewind, null_array, -1);
|
||||
while (same(pobj->o_invoke(s_valid, null_array, -1), true)) {
|
||||
Variant val = pobj->o_invoke(s_current, null_array, -1);
|
||||
if (use_keys) {
|
||||
Variant key = pobj->o_invoke("key", null_array, -1);
|
||||
Variant key = pobj->o_invoke(s_key, null_array, -1);
|
||||
ret.set(key, val);
|
||||
} else {
|
||||
ret.append(val);
|
||||
}
|
||||
pobj->o_invoke("next", null_array, -1);
|
||||
pobj->o_invoke(s_next, null_array, -1);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário