Don't return a const std::string from GetData

It has zero benefit and forces an extra copy.
This commit is contained in:
Thomas Goyne 2014-03-07 16:30:20 -08:00
parent ac25d10d74
commit 9f6124220a
7 changed files with 6 additions and 18 deletions

View File

@ -63,10 +63,6 @@ AssEntry *AssAttachment::Clone() const {
return new AssAttachment(*this);
}
const std::string AssAttachment::GetEntryData() const {
return entry_data;
}
size_t AssAttachment::GetSize() const {
auto header_end = entry_data.get().find('\n');
return entry_data.get().size() - header_end - 1;

View File

@ -46,7 +46,7 @@ public:
/// @param raw If false, remove the SSA filename mangling
std::string GetFileName(bool raw=false) const;
const std::string GetEntryData() const override;
std::string GetEntryData() const override { return entry_data; }
AssEntryGroup Group() const override { return group; }
AssEntry *Clone() const override;

View File

@ -177,14 +177,6 @@ std::string AssDialogue::GetData(bool ssa) const {
return str;
}
const std::string AssDialogue::GetEntryData() const {
return GetData(false);
}
std::string AssDialogue::GetSSAText() const {
return GetData(true);
}
std::auto_ptr<boost::ptr_vector<AssDialogueBlock>> AssDialogue::ParseTags() const {
boost::ptr_vector<AssDialogueBlock> Blocks;

View File

@ -167,10 +167,10 @@ public:
/// Update the text of the line from parsed blocks
void UpdateText(boost::ptr_vector<AssDialogueBlock>& blocks);
const std::string GetEntryData() const override;
std::string GetEntryData() const override { return GetData(false); }
/// Get the line as SSA rather than ASS
std::string GetSSAText() const override;
std::string GetSSAText() const override { return GetData(true); }
/// Does this line collide with the passed line?
bool CollidesWith(const AssDialogue *target) const;

View File

@ -60,7 +60,7 @@ public:
std::string const& GroupHeader(bool ssa=false) const;
/// @brief Get this line's raw entry data in ASS format
virtual const std::string GetEntryData() const=0;
virtual std::string GetEntryData() const=0;
/// Get this line in SSA format
virtual std::string GetSSAText() const { return GetEntryData(); }

View File

@ -28,7 +28,7 @@ public:
AssEntry *Clone() const override { return new AssInfo(*this); }
AssEntryGroup Group() const override { return AssEntryGroup::INFO; }
const std::string GetEntryData() const override { return key + ": " + value; }
std::string GetEntryData() const override { return key + ": " + value; }
std::string GetSSAText() const override { return boost::iequals(key, "scripttype: v4.00+") ? "ScriptType: v4.00" : GetEntryData(); }
std::string Key() const { return key; }

View File

@ -77,7 +77,7 @@ public:
AssStyle();
AssStyle(std::string const& data, int version=1);
const std::string GetEntryData() const override { return data; }
std::string GetEntryData() const override { return data; }
std::string GetSSAText() const override;
AssEntryGroup Group() const override { return AssEntryGroup::STYLE; }
AssEntry *Clone() const override;