Skip to content

Commit

Permalink
Remove the use of boost::flyweight on entry_data
Browse files Browse the repository at this point in the history
  • Loading branch information
Kienyew committed Feb 28, 2022
1 parent d771fb2 commit f7deed1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/ass_attachment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,17 @@ AssAttachment::AssAttachment(agi::fs::path const& name, AssEntryGroup group)
agi::read_file_mapping file(name);
auto buff = file.read();
entry_data = (group == AssEntryGroup::FONT ? "fontname: " : "filename: ") + filename.get() + "\r\n";
entry_data = entry_data.get() + agi::ass::UUEncode(buff, buff + file.size());
entry_data += agi::ass::UUEncode(buff, buff + file.size());
}

size_t AssAttachment::GetSize() const {
auto header_end = entry_data.get().find('\n');
return entry_data.get().size() - header_end - 1;
auto header_end = entry_data.find('\n');
return entry_data.size() - header_end - 1;
}

void AssAttachment::Extract(agi::fs::path const& filename) const {
auto header_end = entry_data.get().find('\n');
auto decoded = agi::ass::UUDecode(entry_data.get().c_str() + header_end + 1, &entry_data.get().back() + 1);
auto header_end = entry_data.find('\n');
auto decoded = agi::ass::UUDecode(entry_data.c_str() + header_end + 1, &entry_data.back() + 1);
agi::io::Save(filename, true).Get().write(&decoded[0], decoded.size());
}

Expand Down
4 changes: 2 additions & 2 deletions src/ass_attachment.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
/// @class AssAttachment
class AssAttachment final : public AssEntry {
/// ASS uuencoded entry data, including header.
boost::flyweight<std::string> entry_data;
std::string entry_data;

/// Name of the attached file, with SSA font mangling if it is a ttf
boost::flyweight<std::string> filename;
Expand All @@ -35,7 +35,7 @@ class AssAttachment final : public AssEntry {
size_t GetSize() const;

/// Add a line of data (without newline) read from a subtitle file
void AddData(std::string const& data) { entry_data = entry_data.get() + data + "\r\n"; }
void AddData(std::string const& data) { entry_data += data + "\r\n"; }

/// Extract the contents of this attachment to a file
/// @param filename Path to save the attachment to
Expand Down

0 comments on commit f7deed1

Please sign in to comment.