diff --git a/hphp/runtime/base/array/array_init.h b/hphp/runtime/base/array/array_init.h index bcab81ffa..3a0809bdf 100644 --- a/hphp/runtime/base/array/array_init.h +++ b/hphp/runtime/base/array/array_init.h @@ -152,16 +152,6 @@ public: return *this; } - ArrayInit &set(litstr name, RefResult v, bool keyConverted = false) { - String key(name); - if (keyConverted) { - m_data->setRef(key, variant(v), false); - } else { - m_data->setRef(key.toKey(), variant(v), false); - } - return *this; - } - ArrayInit &set(CStrRef name, RefResult v, bool keyConverted = false) { if (keyConverted) { m_data->setRef(name, variant(v), false); diff --git a/hphp/runtime/base/builtin_functions.cpp b/hphp/runtime/base/builtin_functions.cpp index 14814d508..bd061b6b5 100644 --- a/hphp/runtime/base/builtin_functions.cpp +++ b/hphp/runtime/base/builtin_functions.cpp @@ -933,9 +933,6 @@ bool isset(CArrRef v, CObjRef offset) { bool isset(CArrRef v, CStrRef offset, bool isString /* = false */) { return isset(v.rvalAtRef(offset, AccessFlags::IsKey(isString))); } -bool isset(CArrRef v, litstr offset, bool isString /* = false */) { - return isset(v.rvalAtRef(offset, AccessFlags::IsKey(isString))); -} bool isset(CArrRef v, CVarRef offset) { return isset(v.rvalAtRef(offset)); } @@ -991,18 +988,6 @@ bool isset(CVarRef v, CVarRef offset) { } return false; } -bool isset(CVarRef v, litstr offset, bool isString /* = false */) { - Variant::TypedValueAccessor tva = v.getTypedAccessor(); - if (LIKELY(Variant::GetAccessorType(tva) == KindOfArray)) { - return isset(Variant::GetAsArray(tva).rvalAtRef( - offset, AccessFlags::IsKey(isString))); - } - if (Variant::GetAccessorType(tva) == KindOfObject || - Variant::IsString(tva)) { - return isset(v, Variant(offset)); - } - return false; -} bool isset(CVarRef v, CStrRef offset, bool isString /* = false */) { Variant::TypedValueAccessor tva = v.getTypedAccessor(); diff --git a/hphp/runtime/base/builtin_functions.h b/hphp/runtime/base/builtin_functions.h index 2733ff240..f80a37e65 100644 --- a/hphp/runtime/base/builtin_functions.h +++ b/hphp/runtime/base/builtin_functions.h @@ -259,7 +259,6 @@ bool isset(CVarRef v, double offset); bool isset(CVarRef v, CArrRef offset); bool isset(CVarRef v, CObjRef offset); bool isset(CVarRef v, CVarRef offset); -bool isset(CVarRef v, litstr offset, bool isString = false); bool isset(CVarRef v, CStrRef offset, bool isString = false); bool isset(CArrRef v, int64_t offset); @@ -269,7 +268,6 @@ inline bool isset(CArrRef v, double offset) { return isset(v, (int64_t)offset); bool isset(CArrRef v, CArrRef offset); bool isset(CArrRef v, CObjRef offset); bool isset(CArrRef v, CVarRef offset); -bool isset(CArrRef v, litstr offset, bool isString = false); bool isset(CArrRef v, CStrRef offset, bool isString = false); inline Variant unset(Variant &v) { v.unset(); return uninit_null();} @@ -293,6 +291,9 @@ inline bool is_array(CVarRef v) { return v.is(KindOfArray);} inline bool is_object(CVarRef var) { return var.is(KindOfObject) && !var.isResource(); } +inline bool is_empty_string(CVarRef v) { + return v.isString() && v.getStringData()->empty(); +} /////////////////////////////////////////////////////////////////////////////// // special variable contexts diff --git a/hphp/runtime/base/execution_context.cpp b/hphp/runtime/base/execution_context.cpp index 1c2ad2862..bf6b281c3 100644 --- a/hphp/runtime/base/execution_context.cpp +++ b/hphp/runtime/base/execution_context.cpp @@ -441,10 +441,13 @@ void BaseExecutionContext::resetCurrentBuffer() { /////////////////////////////////////////////////////////////////////////////// // program executions +static const StaticString s_name("name"); +static const StaticString s_args("args"); + void BaseExecutionContext::registerShutdownFunction(CVarRef function, Array arguments, ShutdownType type) { - Array callback = CREATE_MAP2("name", function, "args", arguments); + Array callback = CREATE_MAP2(s_name, function, s_args, arguments); Variant &funcs = m_shutdowns.lvalAt(type); funcs.append(callback); } @@ -517,7 +520,7 @@ void BaseExecutionContext::onRequestShutdown() { void BaseExecutionContext::executeFunctions(CArrRef funcs) { for (ArrayIter iter(funcs); iter; ++iter) { Array callback = iter.second(); - vm_call_user_func(callback["name"], callback["args"]); + vm_call_user_func(callback[s_name], callback[s_args]); } } @@ -592,6 +595,9 @@ private: int m_originalState; }; +static StaticString s_file("file"); +static StaticString s_line("line"); + void BaseExecutionContext::handleError(const std::string &msg, int errnum, bool callUserHandler, @@ -640,8 +646,8 @@ void BaseExecutionContext::handleError(const std::string &msg, if (RuntimeOption::InjectedStackTrace) { if (!bt.empty()) { Array top = bt.rvalAt(0).toArray(); - if (top.exists("file")) file = top.rvalAt("file").toString(); - if (top.exists("line")) line = top.rvalAt("line"); + if (top.exists(s_file)) file = top.rvalAt(s_file).toString(); + if (top.exists(s_line)) line = top.rvalAt(s_line); } } @@ -670,8 +676,8 @@ bool BaseExecutionContext::callUserErrorHandler(const Exception &e, int errnum, backtrace = arr; Array top = backtrace.rvalAt(0); if (!top.isNull()) { - errfile = top.rvalAt("file"); - errline = top.rvalAt("line").toInt64(); + errfile = top.rvalAt(s_file); + errline = top.rvalAt(s_line).toInt64(); } } } @@ -707,8 +713,8 @@ bool BaseExecutionContext::onFatalError(const Exception &e) { Array bt = ee->getBackTrace(); if (!bt.empty()) { Array top = bt.rvalAt(0).toArray(); - if (top.exists("file")) file = top.rvalAt("file").toString(); - if (top.exists("line")) line = top.rvalAt("line"); + if (top.exists(s_file)) file = top.rvalAt(s_file).toString(); + if (top.exists(s_line)) line = top.rvalAt(s_line); } } } diff --git a/hphp/runtime/base/file/bzip2_file.cpp b/hphp/runtime/base/file/bzip2_file.cpp index 019091496..b96973381 100644 --- a/hphp/runtime/base/file/bzip2_file.cpp +++ b/hphp/runtime/base/file/bzip2_file.cpp @@ -59,12 +59,15 @@ String BZ2File::errstr() { return BZ2_bzerror(m_bzFile, &errnum); } +static const StaticString s_errno("errno"); +static const StaticString s_errstr("errstr"); + Variant BZ2File::error() { assert(m_bzFile); int errnum; const char * errstr; errstr = BZ2_bzerror(m_bzFile, &errnum); - return CREATE_MAP2("errno", errnum, "errstr", String(errstr)); + return CREATE_MAP2(s_errno, errnum, s_errstr, String(errstr)); } bool BZ2File::flush() { diff --git a/hphp/runtime/base/file/http_stream_wrapper.cpp b/hphp/runtime/base/file/http_stream_wrapper.cpp index 88687fa56..045725bf8 100644 --- a/hphp/runtime/base/file/http_stream_wrapper.cpp +++ b/hphp/runtime/base/file/http_stream_wrapper.cpp @@ -24,6 +24,14 @@ namespace HPHP { /////////////////////////////////////////////////////////////////////////////// +static const StaticString s_GET("GET"); +static const StaticString s_method("method"); +static const StaticString s_http("http"); +static const StaticString s_header("header"); +static const StaticString s_max_redirects("max_redirects"); +static const StaticString s_timeout("timeout"); +static const StaticString s_content("content"); + File* HttpStreamWrapper::open(CStrRef filename, CStrRef mode, int options, CVarRef context) { if (RuntimeOption::ServerHttpSafeMode) { @@ -36,33 +44,35 @@ File* HttpStreamWrapper::open(CStrRef filename, CStrRef mode, } std::unique_ptr file; - StreamContext *ctx = !context.isObject() ? nullptr : + StreamContext *ctx = !context.isObject() ? nullptr : context.toObject().getTyped(); - if (!ctx || ctx->m_options.isNull() || ctx->m_options["http"].isNull()) { + if (!ctx || ctx->m_options.isNull() || ctx->m_options[s_http].isNull()) { file = std::unique_ptr(NEWOBJ(UrlFile)()); } else { - Array opts = ctx->m_options["http"]; - String method = "GET"; - if (opts.exists("method")) { - method = opts["method"].toString(); + Array opts = ctx->m_options[s_http]; + String method = s_GET; + if (opts.exists(s_method)) { + method = opts[s_method].toString(); } Array headers; - if (opts.exists("header")) { - Array lines = StringUtil::Explode(opts["header"].toString(), "\r\n"); + if (opts.exists(s_header)) { + Array lines = StringUtil::Explode(opts[s_header].toString(), "\r\n"); for (ArrayIter it(lines); it; ++it) { Array parts = StringUtil::Explode(it.second().toString(), ": "); headers.set(parts.rvalAt(0), parts.rvalAt(1)); } } - if (opts.exists("user_agent") && !headers.exists("User-Agent")) { - headers.set("User-Agent", opts["user_agent"]); + static const StaticString s_user_agent("user_agent"); + static const StaticString s_User_Agent("User-Agent"); + if (opts.exists(s_user_agent) && !headers.exists(s_User_Agent)) { + headers.set(s_User_Agent, opts[s_user_agent]); } int max_redirs = 20; - if (opts.exists("max_redirects")) max_redirs = opts["max_redirects"]; + if (opts.exists(s_max_redirects)) max_redirs = opts[s_max_redirects]; int timeout = -1; - if (opts.exists("timeout")) timeout = opts["timeout"]; + if (opts.exists(s_timeout)) timeout = opts[s_timeout]; file = std::unique_ptr(NEWOBJ(UrlFile)(method.data(), headers, - opts["content"].toString(), + opts[s_content].toString(), max_redirs, timeout)); } bool ret = file->open(filename, mode); diff --git a/hphp/runtime/base/file/ssl_socket.cpp b/hphp/runtime/base/file/ssl_socket.cpp index 27c65f4f5..ff0be5795 100644 --- a/hphp/runtime/base/file/ssl_socket.cpp +++ b/hphp/runtime/base/file/ssl_socket.cpp @@ -42,6 +42,9 @@ int SSLSocket::GetSSLExDataIndex() { return s_ex_data_index; } +static const StaticString s_allow_self_signed("allow_self_signed"); +static const StaticString s_verify_depth("verify_depth"); + static int verify_callback(int preverify_ok, X509_STORE_CTX *ctx) { int ret = preverify_ok; @@ -58,12 +61,12 @@ static int verify_callback(int preverify_ok, X509_STORE_CTX *ctx) { /* if allow_self_signed is set, make sure that verification succeeds */ if (err == X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT && - stream->getContext()["allow_self_signed"].toBoolean()) { + stream->getContext()[s_allow_self_signed].toBoolean()) { ret = 1; } /* check the depth */ - Variant vdepth = stream->getContext()["verify_depth"]; + Variant vdepth = stream->getContext()[s_verify_depth]; if (vdepth.toBoolean() && depth > vdepth.toInt64()) { ret = 0; X509_STORE_CTX_set_error(ctx, X509_V_ERR_CERT_CHAIN_TOO_LONG); @@ -72,10 +75,12 @@ static int verify_callback(int preverify_ok, X509_STORE_CTX *ctx) { return ret; } +static const StaticString s_passphrase("passphrase"); + static int passwd_callback(char *buf, int num, int verify, void *data) { /* TODO: could expand this to make a callback into PHP user-space */ SSLSocket *stream = (SSLSocket *)data; - String passphrase = stream->getContext()["passphrase"]; + String passphrase = stream->getContext()[s_passphrase]; if (!passphrase.empty() && passphrase.size() < num - 1) { memcpy(buf, passphrase.data(), passphrase.size() + 1); return passphrase.size(); @@ -83,17 +88,23 @@ static int passwd_callback(char *buf, int num, int verify, void *data) { return 0; } +static const StaticString s_verify_peer("verify_peer"); +static const StaticString s_cafile("cafile"); +static const StaticString s_capath("capath"); +static const StaticString s_ciphers("ciphers"); +static const StaticString s_local_cert("local_cert"); + SSL *SSLSocket::createSSL(SSL_CTX *ctx) { ERR_clear_error(); /* look at options in the stream and set appropriate verification flags */ - if (m_context["verify_peer"].toBoolean()) { + if (m_context[s_verify_peer].toBoolean()) { /* turn on verification callback */ SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, verify_callback); /* CA stuff */ - String cafile = m_context["cafile"]; - String capath = m_context["capath"]; + String cafile = m_context[s_cafile]; + String capath = m_context[s_capath]; if (!cafile.empty() || !capath.empty()) { if (!SSL_CTX_load_verify_locations(ctx, cafile.data(), capath.data())) { @@ -103,7 +114,7 @@ SSL *SSLSocket::createSSL(SSL_CTX *ctx) { } } - int64_t depth = m_context["verify_depth"].toInt64(); + int64_t depth = m_context[s_verify_depth].toInt64(); if (depth) { SSL_CTX_set_verify_depth(ctx, depth); } @@ -112,18 +123,18 @@ SSL *SSLSocket::createSSL(SSL_CTX *ctx) { } /* callback for the passphrase (for localcert) */ - if (!m_context["passphrase"].toString().empty()) { + if (!m_context[s_passphrase].toString().empty()) { SSL_CTX_set_default_passwd_cb_userdata(ctx, this); SSL_CTX_set_default_passwd_cb(ctx, passwd_callback); } - String cipherlist = m_context["ciphers"].toString(); + String cipherlist = m_context[s_ciphers].toString(); if (cipherlist.empty()) { cipherlist = "DEFAULT"; } SSL_CTX_set_cipher_list(ctx, cipherlist.data()); - String certfile = m_context["local_cert"].toString(); + String certfile = m_context[s_local_cert].toString(); if (!certfile.empty()) { String resolved_path_buff = File::TranslatePath(certfile); if (!resolved_path_buff.empty()) { @@ -428,9 +439,11 @@ bool SSLSocket::setupCrypto(SSLSocket *session /* = NULL */) { return true; } +static const StaticString s_CN_match("CN_match"); + bool SSLSocket::applyVerificationPolicy(X509 *peer) { /* verification is turned off */ - if (!m_context["verify_peer"].toBoolean()) { + if (!m_context[s_verify_peer].toBoolean()) { return true; } @@ -445,7 +458,7 @@ bool SSLSocket::applyVerificationPolicy(X509 *peer) { /* fine */ break; case X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT: - if (m_context["allow_self_signed"].toBoolean()) { + if (m_context[s_allow_self_signed].toBoolean()) { /* allowed */ break; } @@ -459,11 +472,12 @@ bool SSLSocket::applyVerificationPolicy(X509 *peer) { /* if the cert passed the usual checks, apply our own local policies now */ /* Does the common name match ? (used primarily for https://) */ - String cnmatch = m_context["CN_match"].toString(); + String cnmatch = m_context[s_CN_match].toString(); if (!cnmatch.empty()) { X509_NAME *name = X509_get_subject_name(peer); char buf[1024]; - int name_len = X509_NAME_get_text_by_NID(name, NID_commonName, buf, sizeof(buf)); + int name_len = X509_NAME_get_text_by_NID(name, NID_commonName, buf, + sizeof(buf)); if (name_len < 0) { raise_warning("Unable to locate peer certificate CN"); @@ -493,6 +507,11 @@ bool SSLSocket::applyVerificationPolicy(X509 *peer) { return true; } +static const StaticString s_capture_peer_cert("capture_peer_cert"); +static const StaticString s_peer_certificate("peer_certificate"); +static const StaticString s_capture_peer_cert_chain("capture_peer_cert_chain"); +static const StaticString s_peer_certificate_chain("peer_certificate_chain"); + bool SSLSocket::enableCrypto(bool activate /* = true */) { if (activate && !m_ssl_active) { double timeout = m_connect_timeout; @@ -551,13 +570,13 @@ bool SSLSocket::enableCrypto(bool activate /* = true */) { /* allow the script to capture the peer cert * and/or the certificate chain */ - if (m_context["capture_peer_cert"].toBoolean()) { + if (m_context[s_capture_peer_cert].toBoolean()) { Object cert(new Certificate(peer_cert)); - m_context.set("peer_certificate", cert); + m_context.set(s_peer_certificate, cert); peer_cert = nullptr; } - if (m_context["capture_peer_cert_chain"].toBoolean()) { + if (m_context[s_capture_peer_cert_chain].toBoolean()) { Array arr; STACK_OF(X509) *chain = SSL_get_peer_cert_chain(m_handle); if (chain) { @@ -566,7 +585,7 @@ bool SSLSocket::enableCrypto(bool activate /* = true */) { arr.append(Object(new Certificate(mycert))); } } - m_context.set("peer_certificate_chain", arr); + m_context.set(s_peer_certificate_chain, arr); } } diff --git a/hphp/runtime/base/server/rpc_request_handler.cpp b/hphp/runtime/base/server/rpc_request_handler.cpp index 8afc9b9b9..65fc16ab8 100644 --- a/hphp/runtime/base/server/rpc_request_handler.cpp +++ b/hphp/runtime/base/server/rpc_request_handler.cpp @@ -152,6 +152,9 @@ void RPCRequestHandler::handleRequest(Transport *transport) { HttpProtocol::ClearRecord(ret, tmpfile); } +static const StaticString s_output("output"); +static const StaticString s_return("return"); + bool RPCRequestHandler::executePHPFunction(Transport *transport, SourceRootInfo &sourceRootInfo) { // reset timeout counter @@ -276,8 +279,8 @@ bool RPCRequestHandler::executePHPFunction(Transport *transport, case 1: response = m_context->obDetachContents(); break; case 2: response = - f_json_encode(CREATE_MAP2("output", m_context->obDetachContents(), - "return", f_json_encode(funcRet))); + f_json_encode(CREATE_MAP2(s_output, m_context->obDetachContents(), + s_return, f_json_encode(funcRet))); break; case 3: response = f_serialize(funcRet); break; } diff --git a/hphp/runtime/base/server/server_stats.cpp b/hphp/runtime/base/server/server_stats.cpp index db200a9f6..d82c501e8 100644 --- a/hphp/runtime/base/server/server_stats.cpp +++ b/hphp/runtime/base/server/server_stats.cpp @@ -953,6 +953,9 @@ void ServerStats::StartNetworkProfile() { } } +static const StaticString s_ct("ct"); +static const StaticString s_wt("wt"); + Array ServerStats::EndNetworkProfile() { s_profile_network = false; Lock lock(s_lock, false); @@ -966,8 +969,8 @@ Array ServerStats::EndNetworkProfile() { for (IOStatusMap::const_iterator iter = status.begin(); iter != status.end(); ++iter) { ret.set(String(iter->first), - CREATE_MAP2("ct", iter->second.count, - "wt", iter->second.wall_time)); + CREATE_MAP2(s_ct, iter->second.count, + s_wt, iter->second.wall_time)); } status.clear(); } @@ -1217,8 +1220,8 @@ Array ServerStats::getThreadIOStatuses() { for (IOStatusMap::const_iterator iter = status.begin(); iter != status.end(); ++iter) { ret.set(String(iter->first), - CREATE_MAP2("ct", iter->second.count, - "wt", iter->second.wall_time)); + CREATE_MAP2(s_ct, iter->second.count, + s_wt, iter->second.wall_time)); } status.clear(); return ret; diff --git a/hphp/runtime/base/util/extended_logger.cpp b/hphp/runtime/base/util/extended_logger.cpp index d9753f690..3c0cb4986 100644 --- a/hphp/runtime/base/util/extended_logger.cpp +++ b/hphp/runtime/base/util/extended_logger.cpp @@ -128,6 +128,12 @@ void ExtendedLogger::Log(LogLevelType level, CArrRef stackTrace, } } +static const StaticString s_class("class"); +static const StaticString s_function("function"); +static const StaticString s_file("file"); +static const StaticString s_type("type"); +static const StaticString s_line("line"); + void ExtendedLogger::PrintStackTrace(FILE *f, CArrRef stackTrace, bool escape /* = false */, bool escapeMore /* = false */) { @@ -138,17 +144,17 @@ void ExtendedLogger::PrintStackTrace(FILE *f, CArrRef stackTrace, } Array frame = it.second().toArray(); fprintf(f, " #%d ", i); - if (frame.exists("function")) { - if (frame.exists("class")) { - fprintf(f, "%s%s%s(), called ", frame["class"].toString().c_str(), - frame["type"].toString().c_str(), - frame["function"].toString().c_str()); + if (frame.exists(s_function)) { + if (frame.exists(s_class)) { + fprintf(f, "%s%s%s(), called ", frame[s_class].toString().c_str(), + frame[s_type].toString().c_str(), + frame[s_function].toString().c_str()); } else { - fprintf(f, "%s(), called ", frame["function"].toString().c_str()); + fprintf(f, "%s(), called ", frame[s_function].toString().c_str()); } } - fprintf(f, "at [%s:%" PRId64 "]", frame["file"].toString().c_str(), - frame["line"].toInt64()); + fprintf(f, "at [%s:%" PRId64 "]", frame[s_file].toString().c_str(), + frame[s_line].toInt64()); } fprintf(f, escapeMore ? "\\n" : "\n"); fflush(f); @@ -161,19 +167,19 @@ std::string ExtendedLogger::StringOfFrame(CArrRef frame, int i, bool escape) { ss << (escape ? "\\n" : "\n"); } ss << " #" << i << " "; - if (frame.exists("function")) { - if (frame.exists("class")) { - ss << frame["class"].toString().c_str() - << frame["type"].toString().c_str() - << frame["function"].toString().c_str() + if (frame.exists(s_function)) { + if (frame.exists(s_class)) { + ss << frame[s_class].toString().c_str() + << frame[s_type].toString().c_str() + << frame[s_function].toString().c_str() << "(), called "; } else { - ss << frame["function"].toString().c_str() + ss << frame[s_function].toString().c_str() << "(), called "; } } - ss << "at [" << frame["file"].toString().c_str() - << ":" << frame["line"].toInt64() << "]"; + ss << "at [" << frame[s_file].toString().c_str() + << ":" << frame[s_line].toInt64() << "]"; return ss.str(); } diff --git a/hphp/runtime/base/util/http_client.cpp b/hphp/runtime/base/util/http_client.cpp index 9f2ccf251..8dca8972a 100644 --- a/hphp/runtime/base/util/http_client.cpp +++ b/hphp/runtime/base/util/http_client.cpp @@ -101,6 +101,13 @@ int HttpClient::post(const char *url, const char *data, int size, return impl(url, data, size, response, requestHeaders, responseHeaders); } +static const StaticString s_ssl("ssl"); +static const StaticString s_verify_peer("verify_peer"); +static const StaticString s_capath("capath"); +static const StaticString s_cafile("cafile"); +static const StaticString s_local_cert("local_cert"); +static const StaticString s_passphrase("passphrase"); + int HttpClient::impl(const char *url, const char *data, int size, StringBuffer &response, const HeaderMap *requestHeaders, std::vector *responseHeaders) { @@ -184,27 +191,27 @@ int HttpClient::impl(const char *url, const char *data, int size, curl_easy_setopt(cp, CURLOPT_WRITEHEADER, (void*)this); } - if (m_stream_context_options["ssl"].isArray()) { - const Array ssl = m_stream_context_options["ssl"].toArray(); - if (ssl["verify_peer"].toBoolean()) { + if (m_stream_context_options[s_ssl].isArray()) { + const Array ssl = m_stream_context_options[s_ssl].toArray(); + if (ssl[s_verify_peer].toBoolean()) { curl_easy_setopt(cp, CURLOPT_SSL_VERIFYPEER, 1); } - if (ssl.exists("capath")) { + if (ssl.exists(s_capath)) { curl_easy_setopt(cp, CURLOPT_CAPATH, - ssl["capath"].toString().data()); + ssl[s_capath].toString().data()); } - if (ssl.exists("cafile")) { + if (ssl.exists(s_cafile)) { curl_easy_setopt(cp, CURLOPT_CAINFO, - ssl["cafile"].toString().data()); + ssl[s_cafile].toString().data()); } - if (ssl.exists("local_cert")) { + if (ssl.exists(s_local_cert)) { curl_easy_setopt(cp, CURLOPT_SSLKEY, - ssl["local_cert"].toString().data()); + ssl[s_local_cert].toString().data()); curl_easy_setopt(cp, CURLOPT_SSLKEYTYPE, "PEM"); } - if (ssl.exists("passphrase")) { + if (ssl.exists(s_passphrase)) { curl_easy_setopt(cp, CURLOPT_KEYPASSWD, - ssl["passphrase"].toString().data()); + ssl[s_passphrase].toString().data()); } } diff --git a/hphp/runtime/base/util/string_buffer.cpp b/hphp/runtime/base/util/string_buffer.cpp index 88bee3e0d..79609fe6e 100644 --- a/hphp/runtime/base/util/string_buffer.cpp +++ b/hphp/runtime/base/util/string_buffer.cpp @@ -74,7 +74,7 @@ String StringBuffer::detachImpl() { m_cap = 0; return String(str); // causes incref } - return String(""); + return empty_string; } String StringBuffer::copy() { diff --git a/hphp/runtime/eval/debugger/cmd/cmd_machine.cpp b/hphp/runtime/eval/debugger/cmd/cmd_machine.cpp index 80c389186..758805b80 100644 --- a/hphp/runtime/eval/debugger/cmd/cmd_machine.cpp +++ b/hphp/runtime/eval/debugger/cmd/cmd_machine.cpp @@ -174,15 +174,20 @@ bool CmdMachine::AttachSandbox(DebuggerClient *client, return cmdMachine->m_succeed; } +static const StaticString s_host("host"); +static const StaticString s_port("port"); +static const StaticString s_auth("auth"); +static const StaticString s_timeout("timeout"); + void CmdMachine::UpdateIntercept(DebuggerClient *client, const std::string &host, int port) { CmdMachine cmd; cmd.m_body = "rpc"; cmd.m_rpcConfig = CREATE_MAP4 - ("host", String(host), - "port", port ? port : RuntimeOption::DebuggerDefaultRpcPort, - "auth", String(RuntimeOption::DebuggerDefaultRpcAuth), - "timeout", RuntimeOption::DebuggerDefaultRpcTimeout); + (s_host, String(host), + s_port, port ? port : RuntimeOption::DebuggerDefaultRpcPort, + s_auth, String(RuntimeOption::DebuggerDefaultRpcAuth), + s_timeout, RuntimeOption::DebuggerDefaultRpcTimeout); client->xend(&cmd); } diff --git a/hphp/runtime/ext/ext_apc.cpp b/hphp/runtime/ext/ext_apc.cpp index 266be6668..d7ae78c75 100644 --- a/hphp/runtime/ext/ext_apc.cpp +++ b/hphp/runtime/ext/ext_apc.cpp @@ -225,8 +225,10 @@ Variant f_apc_exists(CVarRef key, int64_t cache_id /* = 0 */) { return s_apc_store[cache_id].exists(key.toString()); } +static const StaticString s_start_time("start_time"); + Variant f_apc_cache_info(int64_t cache_id /* = 0 */, bool limited /* = false */) { - return CREATE_MAP1("start_time", start_time()); + return CREATE_MAP1(s_start_time, start_time()); } Array f_apc_sma_info(bool limited /* = false */) { diff --git a/hphp/runtime/ext/ext_domdocument.cpp b/hphp/runtime/ext/ext_domdocument.cpp index 48dba16ce..f84e399d0 100644 --- a/hphp/runtime/ext/ext_domdocument.cpp +++ b/hphp/runtime/ext/ext_domdocument.cpp @@ -305,6 +305,9 @@ static void dom_normalize(xmlNodePtr nodep) { } } +static StaticString s_query("query"); +static StaticString s_namespaces("namespaces"); + static Variant dom_canonicalization(xmlNodePtr nodep, CStrRef file, bool exclusive, bool with_comments, CVarRef xpath_array, CVarRef ns_prefixes, @@ -342,11 +345,11 @@ static Variant dom_canonicalization(xmlNodePtr nodep, CStrRef file, // xpath query from xpath_array Array arr = xpath_array.toArray(); String xquery; - if (!arr.exists("query")) { + if (!arr.exists(s_query)) { raise_warning("'query' missing from xpath array"); return false; } - Variant tmp = arr.rvalAt("query"); + Variant tmp = arr.rvalAt(s_query); if (!tmp.isString()) { raise_warning("'query' is not a string"); return false; @@ -354,8 +357,8 @@ static Variant dom_canonicalization(xmlNodePtr nodep, CStrRef file, xquery = tmp.toString(); ctxp = xmlXPathNewContext(docp); ctxp->node = nodep; - if (arr.exists("namespaces")) { - Variant tmp = arr.rvalAt("namespaces"); + if (arr.exists(s_namespaces)) { + Variant tmp = arr.rvalAt(s_namespaces); if (tmp.isArray()) { for (ArrayIter it = tmp.toArray().begin(); !it; ++it) { Variant prefix = it.first(); diff --git a/hphp/runtime/ext/ext_error.cpp b/hphp/runtime/ext/ext_error.cpp index bf98ed511..355e204b1 100644 --- a/hphp/runtime/ext/ext_error.cpp +++ b/hphp/runtime/ext/ext_error.cpp @@ -55,6 +55,7 @@ static const StaticString s_type("type"); static const StaticString s_function("function"); static const StaticString s_file("file"); static const StaticString s_line("line"); +static const StaticString s_message("message"); String debug_string_backtrace(bool skip) { if (RuntimeOption::InjectedStackTrace) { @@ -95,8 +96,8 @@ Array f_error_get_last() { if (lastError.isNull()) { return (ArrayData *)NULL; } - return CREATE_MAP2("message", g_context->getLastError(), - "type", g_context->getLastErrorNumber()); + return CREATE_MAP2(s_message, g_context->getLastError(), + s_type, g_context->getLastErrorNumber()); } bool f_error_log(CStrRef message, int message_type /* = 0 */, diff --git a/hphp/runtime/ext/ext_fb.cpp b/hphp/runtime/ext/ext_fb.cpp index 50ff8bfa6..002e64b9e 100644 --- a/hphp/runtime/ext/ext_fb.cpp +++ b/hphp/runtime/ext/ext_fb.cpp @@ -1560,6 +1560,12 @@ void f_fb_set_exit_callback(CVarRef function) { g_context->setExitCallback(function); } +static const StaticString s_flush_stats("flush_stats"); +static const StaticString s_chunk_stats("chunk_stats"); +static const StaticString s_total("total"); +static const StaticString s_sent("sent"); +static const StaticString s_time("time"); + Array f_fb_get_flush_stat() { Transport *transport = g_context->getTransport(); if (transport) { @@ -1570,8 +1576,8 @@ Array f_fb_get_flush_stat() { int sent = transport->getResponseSentSize(); int64_t time = transport->getFlushTime(); return CREATE_MAP2( - "flush_stats", CREATE_MAP3("total", total, "sent", sent, "time", time), - "chunk_stats", chunkStats); + s_flush_stats, CREATE_MAP3(s_total, total, s_sent, sent, s_time, time), + s_chunk_stats, chunkStats); } return NULL; } diff --git a/hphp/runtime/ext/ext_function.cpp b/hphp/runtime/ext/ext_function.cpp index 0f64d3459..0af0268b8 100644 --- a/hphp/runtime/ext/ext_function.cpp +++ b/hphp/runtime/ext/ext_function.cpp @@ -34,11 +34,12 @@ namespace HPHP { using HPHP::VM::ActRec; using HPHP::VM::Transl::CallerFrame; +static const StaticString s_internal("internal"); +static const StaticString s_user("user"); + Array f_get_defined_functions() { - Array ret; - ret.set("internal", ClassInfo::GetSystemFunctions()); - ret.set("user", ClassInfo::GetUserFunctions()); - return ret; + return CREATE_MAP2(s_internal, ClassInfo::GetSystemFunctions(), + s_user, ClassInfo::GetUserFunctions()); } bool f_function_exists(CStrRef function_name, bool autoload /* = true */) { @@ -172,6 +173,9 @@ Variant f_call_user_func_array_rpc(CStrRef host, int port, CStrRef auth, return f_call_user_func_rpc(0, host, port, auth, timeout, function, params); } +static const StaticString s_func("func"); +static const StaticString s_args("args"); + Variant f_call_user_func_rpc(int _argc, CStrRef host, int port, CStrRef auth, int timeout, CVarRef function, CArrRef _argv /* = null_array */) { @@ -190,7 +194,7 @@ Variant f_call_user_func_rpc(int _argc, CStrRef host, int port, CStrRef auth, url += "/call_user_func_serialized?auth="; url += auth.data(); - Array blob = CREATE_MAP2("func", function, "args", _argv); + Array blob = CREATE_MAP2(s_func, function, s_args, _argv); String message = f_serialize(blob); vector headers; diff --git a/hphp/runtime/ext/ext_hash.cpp b/hphp/runtime/ext/ext_hash.cpp index c8306c36f..3443dc497 100644 --- a/hphp/runtime/ext/ext_hash.cpp +++ b/hphp/runtime/ext/ext_hash.cpp @@ -166,7 +166,7 @@ static Variant php_hash_do_hash(CStrRef algo, CStrRef data, bool isfilename, ops->hash_init(context); if (isfilename) { - for (Variant chunk = f_fread(f, 1024); !same(chunk, ""); + for (Variant chunk = f_fread(f, 1024); !is_empty_string(chunk); chunk = f_fread(f, 1024)) { String schunk = chunk.toString(); ops->hash_update(context, (unsigned char *)schunk.data(), schunk.size()); @@ -257,7 +257,7 @@ static Variant php_hash_do_hash_hmac(CStrRef algo, CStrRef data, char *K = prepare_hmac_key(ops, context, key); if (isfilename) { - for (Variant chunk = f_fread(f, 1024); !same(chunk, ""); + for (Variant chunk = f_fread(f, 1024); !is_empty_string(chunk); chunk = f_fread(f, 1024)) { String schunk = chunk.toString(); ops->hash_update(context, (unsigned char *)schunk.data(), schunk.size()); @@ -327,7 +327,7 @@ bool f_hash_update_file(CObjRef init_context, CStrRef filename, } HashContext *hash = init_context.getTyped(); - for (Variant chunk = f_fread(f, 1024); !same(chunk, ""); + for (Variant chunk = f_fread(f, 1024); !is_empty_string(chunk); chunk = f_fread(f, 1024)) { String schunk = chunk.toString(); hash->ops->hash_update(hash->context, (unsigned char *)schunk.data(), @@ -342,7 +342,7 @@ int64_t f_hash_update_stream(CObjRef context, CObjRef handle, int didread = 0; while (length) { Variant chunk = f_fread(handle, length > 0 ? length : 1024); - if (same(chunk, "")) { + if (is_empty_string(chunk)) { return didread; } String schunk = chunk.toString(); diff --git a/hphp/runtime/ext/ext_image.cpp b/hphp/runtime/ext/ext_image.cpp index ed516c2ef..3e32fdcb1 100644 --- a/hphp/runtime/ext/ext_image.cpp +++ b/hphp/runtime/ext/ext_image.cpp @@ -756,7 +756,7 @@ static int php_read_APP(CObjRef stream, unsigned int marker, Variant &info) { length -= 2; /* length includes itself */ buffer = f_fread(stream, (long)length); - if (same(buffer, "")) { + if (is_empty_string(buffer)) { return 0; } diff --git a/hphp/runtime/ext/ext_memcached.cpp b/hphp/runtime/ext/ext_memcached.cpp index a8729e79c..b60faa436 100644 --- a/hphp/runtime/ext/ext_memcached.cpp +++ b/hphp/runtime/ext/ext_memcached.cpp @@ -368,6 +368,10 @@ bool c_Memcached::getMultiImpl(CStrRef server_key, CArrRef keys, keysCopy.size())); } +static const StaticString s_key("key"); +static const StaticString s_value("value"); +static const StaticString s_cas("cas"); + bool c_Memcached::fetchImpl(memcached_result_st &result, Array &item) { memcached_return status; if (!memcached_fetch_result(&m_impl->memcached, &result, &status)) { @@ -386,7 +390,7 @@ bool c_Memcached::fetchImpl(memcached_result_st &result, Array &item) { String sKey(key, keyLength, CopyString); double cas = (double) memcached_result_cas(&result); - item = CREATE_MAP3("key", sKey, "value", value, "cas", cas); + item = CREATE_MAP3(s_key, sKey, s_value, value, s_cas, cas); return true; } @@ -595,12 +599,17 @@ bool c_Memcached::t_addservers(CArrRef servers) { } namespace { + +static const StaticString s_host("host"); +static const StaticString s_port("port"); +static const StaticString s_weight("weight"); + memcached_return_t doServerListCallback(const memcached_st *ptr, memcached_server_instance_st server, void *context) { Array *returnValue = (Array*) context; - returnValue->append(CREATE_MAP3("host", String(server->hostname, CopyString), - "port", (int32_t)server->port, - "weight", (int32_t)server->weight)); + returnValue->append(CREATE_MAP3(s_host, String(server->hostname, CopyString), + s_port, (int32_t)server->port, + s_weight, (int32_t)server->weight)); return MEMCACHED_SUCCESS; } } @@ -627,9 +636,9 @@ Variant c_Memcached::t_getserverbykey(CStrRef server_key) { return false; } - Array returnValue = CREATE_MAP3("host", String(server->hostname, CopyString), - "port", (int32_t)server->port, - "weight", (int32_t)server->weight); + Array returnValue = CREATE_MAP3(s_host, String(server->hostname, CopyString), + s_port, (int32_t)server->port, + s_weight, (int32_t)server->weight); return returnValue; } @@ -639,6 +648,32 @@ struct StatsContext { Array returnValue; }; +static const StaticString s_pid("pid"); +static const StaticString s_uptime("uptime"); +static const StaticString s_threads("threads"); +static const StaticString s_time("time"); +static const StaticString s_pointer_size("pointer_size"); +static const StaticString s_rusage_user_seconds("rusage_user_seconds"); +static const StaticString s_rusage_user_microseconds("rusage_user_microseconds"); +static const StaticString s_rusage_system_seconds("rusage_system_seconds"); +static const StaticString + s_rusage_system_microseconds("rusage_system_microseconds"); +static const StaticString s_curr_items("curr_items"); +static const StaticString s_total_items("total_items"); +static const StaticString s_limit_maxbytes("limit_maxbytes"); +static const StaticString s_curr_connections("curr_connections"); +static const StaticString s_total_connections("total_connections"); +static const StaticString s_connection_structures("connection_structures"); +static const StaticString s_bytes("bytes"); +static const StaticString s_cmd_get("cmd_get"); +static const StaticString s_cmd_set("cmd_set"); +static const StaticString s_get_hits("get_hits"); +static const StaticString s_get_misses("get_misses"); +static const StaticString s_evictions("evictions"); +static const StaticString s_bytes_read("bytes_read"); +static const StaticString s_bytes_written("bytes_written"); +static const StaticString s_version("version"); + memcached_return_t doStatsCallback(const memcached_st *ptr, memcached_server_instance_st server, void *inContext) { StatsContext *context = (StatsContext*) inContext; @@ -648,32 +683,32 @@ memcached_return_t doStatsCallback(const memcached_st *ptr, ssize_t i = context->returnValue.size(); context->returnValue.set(String(key, CopyString), Array(ArrayInit(24) - .set("pid", (int64_t)stats[i].pid) - .set("uptime", (int64_t)stats[i].uptime) - .set("threads", (int64_t)stats[i].threads) - .set("time", (int64_t)stats[i].time) - .set("pointer_size", (int64_t)stats[i].pointer_size) - .set("rusage_user_seconds", (int64_t)stats[i].rusage_user_seconds) - .set("rusage_user_microseconds", (int64_t)stats[i] + .set(s_pid, (int64_t)stats[i].pid) + .set(s_uptime, (int64_t)stats[i].uptime) + .set(s_threads, (int64_t)stats[i].threads) + .set(s_time, (int64_t)stats[i].time) + .set(s_pointer_size, (int64_t)stats[i].pointer_size) + .set(s_rusage_user_seconds, (int64_t)stats[i].rusage_user_seconds) + .set(s_rusage_user_microseconds, (int64_t)stats[i] .rusage_user_microseconds) - .set("rusage_system_seconds", (int64_t)stats[i].rusage_system_seconds) - .set("rusage_system_microseconds", (int64_t)stats[i] + .set(s_rusage_system_seconds, (int64_t)stats[i].rusage_system_seconds) + .set(s_rusage_system_microseconds, (int64_t)stats[i] .rusage_system_microseconds) - .set("curr_items", (int64_t)stats[i].curr_items) - .set("total_items", (int64_t)stats[i].total_items) - .set("limit_maxbytes", (int64_t)stats[i].limit_maxbytes) - .set("curr_connections", (int64_t)stats[i].curr_connections) - .set("total_connections", (int64_t)stats[i].total_connections) - .set("connection_structures", (int64_t)stats[i].connection_structures) - .set("bytes", (int64_t)stats[i].bytes) - .set("cmd_get", (int64_t)stats[i].cmd_get) - .set("cmd_set", (int64_t)stats[i].cmd_set) - .set("get_hits", (int64_t)stats[i].get_hits) - .set("get_misses", (int64_t)stats[i].get_misses) - .set("evictions", (int64_t)stats[i].evictions) - .set("bytes_read", (int64_t)stats[i].bytes_read) - .set("bytes_written", (int64_t)stats[i].bytes_written) - .set("version", String(stats[i].version, CopyString)) + .set(s_curr_items, (int64_t)stats[i].curr_items) + .set(s_total_items, (int64_t)stats[i].total_items) + .set(s_limit_maxbytes, (int64_t)stats[i].limit_maxbytes) + .set(s_curr_connections, (int64_t)stats[i].curr_connections) + .set(s_total_connections, (int64_t)stats[i].total_connections) + .set(s_connection_structures, (int64_t)stats[i].connection_structures) + .set(s_bytes, (int64_t)stats[i].bytes) + .set(s_cmd_get, (int64_t)stats[i].cmd_get) + .set(s_cmd_set, (int64_t)stats[i].cmd_set) + .set(s_get_hits, (int64_t)stats[i].get_hits) + .set(s_get_misses, (int64_t)stats[i].get_misses) + .set(s_evictions, (int64_t)stats[i].evictions) + .set(s_bytes_read, (int64_t)stats[i].bytes_read) + .set(s_bytes_written, (int64_t)stats[i].bytes_written) + .set(s_version, String(stats[i].version, CopyString)) .create())); return MEMCACHED_SUCCESS; diff --git a/hphp/runtime/ext/ext_misc.cpp b/hphp/runtime/ext/ext_misc.cpp index c884e1c95..a3c51ab8c 100644 --- a/hphp/runtime/ext/ext_misc.cpp +++ b/hphp/runtime/ext/ext_misc.cpp @@ -226,6 +226,9 @@ void f_usleep(int micro_seconds) { usleep(micro_seconds); } +static const StaticString s_seconds("seconds"); +static const StaticString s_nanoseconds("nanoseconds"); + Variant f_time_nanosleep(int seconds, int nanoseconds) { if (seconds < 0) { throw_invalid_argument("seconds: cannot be negative"); @@ -245,8 +248,8 @@ Variant f_time_nanosleep(int seconds, int nanoseconds) { return true; } if (errno == EINTR) { - return CREATE_MAP2("seconds", (int64_t)rem.tv_sec, - "nanoseconds", (int64_t)rem.tv_nsec); + return CREATE_MAP2(s_seconds, (int64_t)rem.tv_sec, + s_nanoseconds, (int64_t)rem.tv_nsec); } return false; } @@ -351,8 +354,10 @@ String f_token_name(int64_t token) { return "UNKNOWN"; } +static const StaticString s_marauder("I solemnly swear that I am up to no good."); + Variant f_hphp_process_abort(CVarRef magic) { - if (magic.equal("I solemnly swear that I am up to no good.")) { + if (magic.equal(s_marauder)) { *((int*)0) = 0xdead; } return null_variant; diff --git a/hphp/runtime/ext/ext_options.cpp b/hphp/runtime/ext/ext_options.cpp index 85e8642c7..285a268fd 100644 --- a/hphp/runtime/ext/ext_options.cpp +++ b/hphp/runtime/ext/ext_options.cpp @@ -565,7 +565,25 @@ Array f_getopt(CStrRef options, CVarRef longopts /* = null_variant */) { /////////////////////////////////////////////////////////////////////////////// -#define PHP_RUSAGE_PARA(a) #a, (int64_t)usg.a +static const StaticString s_ru_oublock("ru_oublock"); +static const StaticString s_ru_inblock("ru_inblock"); +static const StaticString s_ru_msgsnd("ru_msgsnd"); +static const StaticString s_ru_msgrcv("ru_msgrcv"); +static const StaticString s_ru_maxrss("ru_maxrss"); +static const StaticString s_ru_ixrss("ru_ixrss"); +static const StaticString s_ru_idrss("ru_idrss"); +static const StaticString s_ru_minflt("ru_minflt"); +static const StaticString s_ru_majflt("ru_majflt"); +static const StaticString s_ru_nsignals("ru_nsignals"); +static const StaticString s_ru_nvcsw("ru_nvcsw"); +static const StaticString s_ru_nivcsw("ru_nivcsw"); +static const StaticString s_ru_nswap("ru_nswap"); +static const StaticString s_ru_utime_tv_usec("ru_utime.tv_usec"); +static const StaticString s_ru_utime_tv_sec("ru_utime.tv_sec"); +static const StaticString s_ru_stime_tv_usec("ru_stime.tv_usec"); +static const StaticString s_ru_stime_tv_sec("ru_stime.tv_sec"); + +#define PHP_RUSAGE_PARA(a) s_ ## a, (int64_t)usg.a Array f_getrusage(int who /* = 0 */) { struct rusage usg; memset(&usg, 0, sizeof(struct rusage)); @@ -588,10 +606,10 @@ Array f_getrusage(int who /* = 0 */) { set(PHP_RUSAGE_PARA(ru_nvcsw)). set(PHP_RUSAGE_PARA(ru_nivcsw)). set(PHP_RUSAGE_PARA(ru_nswap)). - set(PHP_RUSAGE_PARA(ru_utime.tv_usec)). - set(PHP_RUSAGE_PARA(ru_utime.tv_sec)). - set(PHP_RUSAGE_PARA(ru_stime.tv_usec)). - set(PHP_RUSAGE_PARA(ru_stime.tv_sec)). + set(s_ru_utime_tv_usec, (int64_t)usg.ru_utime.tv_usec). + set(s_ru_utime_tv_sec, (int64_t)usg.ru_utime.tv_sec). + set(s_ru_stime_tv_usec, (int64_t)usg.ru_stime.tv_usec). + set(s_ru_stime_tv_sec, (int64_t)usg.ru_stime.tv_sec). create()); } diff --git a/hphp/runtime/ext/ext_stream.cpp b/hphp/runtime/ext/ext_stream.cpp index abcf5857d..3502f73d9 100644 --- a/hphp/runtime/ext/ext_stream.cpp +++ b/hphp/runtime/ext/ext_stream.cpp @@ -225,12 +225,15 @@ bool f_stream_set_blocking(CObjRef stream, int mode) { return fcntl(file->fd(), F_SETFL, flags) != -1; } +static const StaticString s_sec("sec"); +static const StaticString s_usec("usec"); + bool f_stream_set_timeout(CObjRef stream, int seconds, int microseconds /* = 0 */) { if (stream.getTyped(false, true)) { return f_socket_set_option (stream, SOL_SOCKET, SO_RCVTIMEO, - CREATE_MAP2("sec", seconds, "usec", microseconds)); + CREATE_MAP2(s_sec, seconds, s_usec, microseconds)); } return false; } diff --git a/hphp/runtime/ext/mailparse/mime.cpp b/hphp/runtime/ext/mailparse/mime.cpp index ae1415320..7035c74dc 100644 --- a/hphp/runtime/ext/mailparse/mime.cpp +++ b/hphp/runtime/ext/mailparse/mime.cpp @@ -496,10 +496,12 @@ MimePart *MimePart::getParent() { return m_parent.getTyped(); } +static const StaticString s_headers("headers"); + Variant MimePart::getPartData() { Array ret = Array::Create(); - ret.set("headers", m_headers); + ret.set(s_headers, m_headers); ret.set("starting-pos", m_startpos); ret.set("starting-pos-body", m_bodystart); diff --git a/hphp/runtime/ext/soap/xml.cpp b/hphp/runtime/ext/soap/xml.cpp index caafa757f..7e5b48060 100644 --- a/hphp/runtime/ext/soap/xml.cpp +++ b/hphp/runtime/ext/soap/xml.cpp @@ -69,6 +69,9 @@ static void soap_ignorableWhitespace(void *ctx, const xmlChar *ch, int len) { static void soap_Comment(void *ctx, const xmlChar *value) { } +static StaticString s_http("http"); +static StaticString s_timeout("timeout"); + xmlDocPtr soap_xmlParseFile(const char *filename) { String cache_key("HPHP.SOAP.WSDL."); cache_key += filename; @@ -76,7 +79,7 @@ xmlDocPtr soap_xmlParseFile(const char *filename) { Variant content = f_apc_fetch(cache_key); if (same(content, false)) { Variant stream = File::Open(filename, "rb", 0, f_stream_context_create( - CREATE_MAP1("http", CREATE_MAP1("timeout", 1000)))); + CREATE_MAP1(s_http, CREATE_MAP1(s_timeout, 1000)))); if (!same(stream, false)) { content = f_stream_get_contents(stream); if (!same(content, false)) { diff --git a/hphp/test/test_ext_array.cpp b/hphp/test/test_ext_array.cpp index bea628d55..e8e72d6f5 100644 --- a/hphp/test/test_ext_array.cpp +++ b/hphp/test/test_ext_array.cpp @@ -448,7 +448,7 @@ bool TestExtArray::test_array_map() { bool TestExtArray::test_array_merge_recursive() { { Variant a1 = Array::Create(); - Variant a2 = CREATE_MAP1("key1", ref(a1)); + Variant a2 = CREATE_MAP1(String("key1"), ref(a1)); a1 = f_array_merge_recursive(a1, a2); } { @@ -540,8 +540,8 @@ bool TestExtArray::test_array_merge() { } { Variant v = 1; - Array a = CREATE_MAP1("one", 1); - Array b = CREATE_MAP1("two", ref(v)); + Array a = CREATE_MAP1(String("one"), 1); + Array b = CREATE_MAP1(String("two"), ref(v)); Array r = f_array_merge(2, a, CREATE_VECTOR1(b)); v = 2; VS(f_print_r(r, true), @@ -640,8 +640,8 @@ bool TestExtArray::test_array_replace() { } { Variant v = 1; - Array a = CREATE_MAP1("one", 1); - Array b = CREATE_MAP1("two", ref(v)); + Array a = CREATE_MAP1(String("one"), 1); + Array b = CREATE_MAP1(String("two"), ref(v)); Array r = f_array_replace(2, a, CREATE_VECTOR1(b)); v = 2; VS(f_print_r(r, true),