Skip to content

Unnecessary subtitleData.data copying #72

@mgoral

Description

@mgoral

We don't need to copy (clone) it all the time. For instance, whenever ChangeData command isn't executed, it's probably not a place for a whole copy. Example from SubtitleTabs.py:

def _updateFile(self, filePath):
    items = self.__fileList.findItems(filePath, Qt.MatchExactly)
    if len(items) > 0:
        data = self._subtitleData.data(filePath)
        for item in items:
            item.setText(1, data.inputEncoding)
            item.setText(2, data.outputEncoding)
            item.setText(3, data.outputFormat.NAME)
            item.setText(4, str(data.fps))

            videoIcon = QIcon(":/img/film.png") if data.videoPath is not None else QIcon()
            item.setIcon(4, videoIcon)

We don't even use subtitles here. Instead, we could introduce e.g. non-copying accessors in DataModel for encodings, fps and things like that.

OR EVEN BETTER: make subtitles copy-on-write (copy-on-edit, frankly).

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions