int Block::declareVariable(CStrRef var) { ASSERT(var->isStatic()); VariableIndices::const_iterator it = m_variableIndices.find(var); if (it == m_variableIndices.end()) { int i = m_variableIndices.size(); m_variableIndices[var].set(var, i); return i; } return it->second.idx(); }
void VariableSerializer::write(CStrRef v) { if (m_type == APCSerialize && !v.isNull() && v->isStatic()) { union { char buf[8]; StringData *sd; } u; u.sd = v.get(); m_buf->append("S:"); m_buf->append(u.buf, 8); m_buf->append(';'); } else { v.serialize(this); } }
bool ConcurrentTableSharedStore::constructPrime(CStrRef v, KeyValuePair& item, bool serialized) { if (s_apc_file_storage.getState() != SharedStoreFileStorage::StateInvalid && (!v->isStatic() || serialized)) { // StaticString for non-object should consume limited amount of space, // not worth going through the file storage // TODO: currently we double serialize string for uniform handling later, // hopefully the unserialize won't be called often. We could further // optimize by storing more type info. String s = apc_serialize(v); char *sAddr = s_apc_file_storage.put(s.data(), s.size()); if (sAddr) { item.sAddr = sAddr; item.sSize = serialized ? 0 - s.size() : s.size(); return false; } } item.value = SharedVariant::Create(v, serialized); return true; }