mirror of
https://github.com/beetbox/beets.git
synced 2026-02-11 18:02:10 +01:00
item fields no longer dirtied if unchanged when assigned
This is especially important for read(), which will assign many times while, in many cases, causing few actual changes. A store() that follows soon after will now be much more lightweight. --HG-- extra : convert_revision : svn%3A41726ec3-264d-0410-9c23-a9f1637257cc/trunk%4079
This commit is contained in:
parent
e811b72763
commit
fb4344e937
2 changed files with 9 additions and 3 deletions
|
|
@ -121,8 +121,10 @@ class Item(object):
|
|||
Otherwise, performs an ordinary setattr."""
|
||||
|
||||
if key in item_keys:
|
||||
self.record[key] = value
|
||||
self.dirty[key] = True
|
||||
if (not (key in self.record)) or (self.record[key] != value):
|
||||
# don't dirty if value unchanged
|
||||
self.record[key] = value
|
||||
self.dirty[key] = True
|
||||
else:
|
||||
object.__setattr__(self, key, value)
|
||||
|
||||
|
|
|
|||
|
|
@ -117,8 +117,12 @@ class GetSetTest(unittest.TestCase):
|
|||
self.assertEqual(self.i.bpm, 4915)
|
||||
|
||||
def test_set_sets_dirty_flag(self):
|
||||
self.i.comp = True
|
||||
self.i.comp = not self.i.comp
|
||||
self.assertTrue(self.i.dirty['comp'])
|
||||
|
||||
def test_set_does_not_dirty_if_value_unchanged(self):
|
||||
self.i.title = self.i.title
|
||||
self.assertTrue(not self.i.dirty['title'])
|
||||
|
||||
class DestinationTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
|
|
|
|||
Loading…
Reference in a new issue