Reverted to direct array access instead of std::map emplace

This commit is contained in:
Takeshi Nakatani 2023-08-19 04:14:10 +00:00 committed by Andrew Gaul
parent 7e94b64ae7
commit 6781ef5bd1
2 changed files with 6 additions and 3 deletions

View File

@ -3739,7 +3739,7 @@ static size_t parse_xattrs(const std::string& strxattrs, xattrs_t& xattrs)
// something format error, so skip this.
continue;
}
xattrs.emplace(std::move(key), std::move(val));
xattrs[key] = val;
}
return xattrs.size();
}
@ -3805,8 +3805,7 @@ static int set_xattrs_to_header(headers_t& meta, const char* name, const char* v
parse_xattrs(strxattrs, xattrs);
// add name(do not care overwrite and empty name/value)
std::string val(value, size);
xattrs.emplace(name, std::move(val));
xattrs[name] = std::string(value, size);
// build new strxattrs(not encoded) and set it to headers_t
meta["x-amz-meta-xattr"] = build_xattrs(xattrs);

View File

@ -815,6 +815,10 @@ function test_extended_attributes {
touch "${TEST_TEXT_FILE}"
# set value
set_xattr key1 value0 "${TEST_TEXT_FILE}"
get_xattr key1 "${TEST_TEXT_FILE}" | grep -q '^value0$'
# over write value
set_xattr key1 value1 "${TEST_TEXT_FILE}"
get_xattr key1 "${TEST_TEXT_FILE}" | grep -q '^value1$'