Avoid writing duplicate tags when saving ASF files.

Reduce memory reallocations and copies when saving ASF files.
This commit is contained in:
Tsuda Kageyu
2015-08-04 13:50:09 +09:00
parent 779f904940
commit 6dc8d701a8
2 changed files with 31 additions and 5 deletions

View File

@ -25,6 +25,7 @@ class TestASF : public CppUnit::TestFixture
CPPUNIT_TEST(testSavePicture);
CPPUNIT_TEST(testSaveMultiplePictures);
CPPUNIT_TEST(testProperties);
CPPUNIT_TEST(testRepeatedSave);
CPPUNIT_TEST_SUITE_END();
public:
@ -270,6 +271,21 @@ public:
CPPUNIT_ASSERT_EQUAL(StringList("3"), tags["DISCNUMBER"]);
}
void testRepeatedSave()
{
ScopedFileCopy copy("silence-1", ".wma");
{
ASF::File f(copy.fileName().c_str());
f.tag()->setTitle(std::string(128 * 1024, 'X').c_str());
f.save();
CPPUNIT_ASSERT_EQUAL(297578L, f.length());
f.tag()->setTitle(std::string(16 * 1024, 'X').c_str());
f.save();
CPPUNIT_ASSERT_EQUAL(68202L, f.length());
}
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(TestASF);