static constexpr uint32_t MAX_TAG_VAL_SIZE=256;
bool RGWObjTags::add_tag(const string&key, const string& val){
- return tags.emplace(std::make_pair(key,val)).second;
+ return tag_map.emplace(std::make_pair(key,val)).second;
}
int RGWObjTags::check_and_add_tag(const string&key, const string& val){
- if (tags.size() == MAX_OBJ_TAGS ||
+ if (tag_map.size() == MAX_OBJ_TAGS ||
key.size() > MAX_TAG_KEY_SIZE ||
val.size() > MAX_TAG_VAL_SIZE ||
key.size() == 0){
#ifndef RGW_TAG_H
#define RGW_TAG_H
-#include <map>
#include <string>
#include <include/types.h>
+#include <boost/container/flat_map.hpp>
#include "rgw_common.h"
class RGWObjTags
{
protected:
- std::map <std::string, std::string> tags;
+ using tag_map_t = boost::container::flat_map <std::string, std::string>;
+ tag_map_t tag_map;
public:
RGWObjTags() {}
~RGWObjTags() {}
void encode(bufferlist& bl) const {
ENCODE_START(1,1,bl);
- ::encode(tags, bl);
+ ::encode(tag_map, bl);
ENCODE_FINISH(bl);
}
void decode(bufferlist::iterator &bl) {
DECODE_START_LEGACY_COMPAT_LEN(1, 1, 1, bl);
- ::decode(tags,bl);
+ ::decode(tag_map,bl);
DECODE_FINISH(bl);
}
void dump(Formatter *f) const;
bool add_tag(const std::string& key, const std::string& val="");
int check_and_add_tag(const std::string& key, const std::string& val="");
- size_t count() const {return tags.size();}
+ size_t count() const {return tag_map.size();}
int set_from_string(const std::string& input);
- const map <std::string,std::string>& get_tags() const {return tags;}
+ const tag_map_t& get_tags() const {return tag_map;}
};
WRITE_CLASS_ENCODER(RGWObjTags)
int RGWObjTagSet_S3::rebuild(RGWObjTags& dest){
int ret;
- for (const auto &it: tags){
+ for (const auto &it: tag_map){
ret = dest.check_and_add_tag(it.first, it.second);
if (ret < 0)
return ret;
}
void RGWObjTagSet_S3::dump_xml(Formatter *f){
- for (const auto& tag: tags){
+ for (const auto& tag: tag_map){
f->open_object_section("Tag");
f->dump_string("Key", tag.first);
f->dump_string("Value", tag.second);