aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/case_insensitive_string/case_insensitive_string.cpp
blob: 16c0f5ff7a210a89b43d677395d4f315c5bf3ba3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include "case_insensitive_string.h"

#include <library/cpp/digest/murmur/murmur.h>

size_t THash<TCaseInsensitiveStringBuf>::operator()(TCaseInsensitiveStringBuf str) const noexcept {
    TMurmurHash2A<size_t> hash;
    for (size_t i = 0; i < str.size(); ++i) {
        char lower = std::tolower(str[i]);
        hash.Update(&lower, 1);
    }
    return hash.Value();
}

template <>
void Out<TCaseInsensitiveString>(IOutputStream& o, const TCaseInsensitiveString& p) {
    o.Write(p.data(), p.size());
}

template <>
void Out<TCaseInsensitiveStringBuf>(IOutputStream& o, const TCaseInsensitiveStringBuf& p) {
    o.Write(p.data(), p.size());
}