| 75 | } |
| 76 | |
| 77 | void set(const char* data, int32_t len) { |
| 78 | BOLT_CHECK_GE(len, 0); |
| 79 | BOLT_DCHECK(data || len == 0); |
| 80 | size_ = len; |
| 81 | if (isInline()) { |
| 82 | // Zero the inline part. |
| 83 | // this makes sure that inline strings can be compared for equality with 2 |
| 84 | // int64 compares. |
| 85 | memset(prefix_, 0, kPrefixSize); |
| 86 | if (size_ == 0) { |
| 87 | return; |
| 88 | } |
| 89 | // small string: inlined. Zero the last 8 bytes first to allow for whole |
| 90 | // word comparison. |
| 91 | value_.data = nullptr; |
| 92 | memcpy(prefix_, data, size_); |
| 93 | } else { |
| 94 | // large string: store pointer |
| 95 | memcpy(prefix_, data, kPrefixSize); |
| 96 | value_.data = data; |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | static StringView makeInline(std::string str) { |
| 101 | BOLT_DCHECK(isInline(str.size())); |
no test coverage detected