From b541ec8b682d51f5640ac33f6de2d33cb600bb80 Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Mon, 30 Nov 2015 12:35:29 +0900 Subject: [PATCH] Remove some private data members not needed to be carried. --- taglib/mpeg/id3v1/id3v1tag.cpp | 30 ++++++++++++++---------------- taglib/mpeg/id3v1/id3v1tag.h | 2 +- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/taglib/mpeg/id3v1/id3v1tag.cpp b/taglib/mpeg/id3v1/id3v1tag.cpp index f4004184..4a7d50d6 100644 --- a/taglib/mpeg/id3v1/id3v1tag.cpp +++ b/taglib/mpeg/id3v1/id3v1tag.cpp @@ -35,10 +35,9 @@ using namespace ID3v1; class ID3v1::Tag::TagPrivate { public: - TagPrivate() : file(0), tagOffset(-1), track(0), genre(255) {} - - File *file; - long tagOffset; + TagPrivate() : + track(0), + genre(255) {} String title; String artist; @@ -81,18 +80,17 @@ ByteVector ID3v1::StringHandler::render(const String &s) const // public methods //////////////////////////////////////////////////////////////////////////////// -ID3v1::Tag::Tag() : TagLib::Tag() +ID3v1::Tag::Tag() : + TagLib::Tag(), + d(new TagPrivate()) { - d = new TagPrivate; } -ID3v1::Tag::Tag(File *file, long tagOffset) : TagLib::Tag() +ID3v1::Tag::Tag(File *file, long tagOffset) : + TagLib::Tag(), + d(new TagPrivate()) { - d = new TagPrivate; - d->file = file; - d->tagOffset = tagOffset; - - read(); + read(file, tagOffset); } ID3v1::Tag::~Tag() @@ -214,12 +212,12 @@ void ID3v1::Tag::setStringHandler(const StringHandler *handler) // protected methods //////////////////////////////////////////////////////////////////////////////// -void ID3v1::Tag::read() +void ID3v1::Tag::read(File *file, long tagOffset) { - if(d->file && d->file->isValid()) { - d->file->seek(d->tagOffset); + if(file && file->isValid()) { + file->seek(tagOffset); // read the tag -- always 128 bytes - ByteVector data = d->file->readBlock(128); + const ByteVector data = file->readBlock(128); // some initial sanity checking if(data.size() == 128 && data.startsWith("TAG")) diff --git a/taglib/mpeg/id3v1/id3v1tag.h b/taglib/mpeg/id3v1/id3v1tag.h index 4cba00db..02642ca5 100644 --- a/taglib/mpeg/id3v1/id3v1tag.h +++ b/taglib/mpeg/id3v1/id3v1tag.h @@ -183,7 +183,7 @@ namespace TagLib { /*! * Reads from the file specified in the constructor. */ - void read(); + void read(File *file, long tagOffset); /*! * Pareses the body of the tag in \a data. */ -- 2.40.0