Exemple #1
0
    static_string ( const char *str ) {
		euint32 hash_value = calc_hashnr ( str, _strlen ( str ) );
		xhn::hash_set<string>::bucket& b = s_static_string_set.get_bucket(hash_value);
		{
			SpinLock::Instance inst = b.m_lock.Lock();
			xhn::list<xhn::string>::iterator iter = b.begin();
			xhn::list<xhn::string>::iterator end = b.begin();
			for (; iter != end; iter++) {
				if (*iter == str) {
					m_str = (*iter).c_str();
					return;
				}
			}
		}
		string value ( str );
		const string &v = s_static_string_set.insert ( value );
		m_str = v.c_str();
    }
Exemple #2
0
    static_string ( const char *str ) {
        if (!s_static_string_set) {
            s_static_string_set = VNEW hash_set<string>;
        }

		euint32 hash_value = calc_hashnr ( str, strlen ( str ) );
		xhn::hash_set<string>::bucket& b = s_static_string_set->get_bucket(hash_value);
		{
			SpinLock::Instance inst = b.m_lock.Lock();
			xhn::list<xhn::string>::iterator iter = b.begin();
			xhn::list<xhn::string>::iterator end = b.end();
			for (; iter != end; iter++) {
				if (strcmp(iter->c_str(),str) == 0) {
					m_str = iter->c_str();
					return;
				}
			}
		}

		string value ( str );
		const string &v = s_static_string_set->insert ( value );
		m_str = v.c_str();
    }