Skip to content

Commit bc400be

Browse files
stlrnznicolas-grekas
authored andcommitted
compare data before marking lock as changed
1 parent e34c826 commit bc400be

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/Lock.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,18 @@ public function get($name)
4949

5050
public function set($name, $data)
5151
{
52-
$this->lock[$name] = $data;
53-
$this->changed = true;
52+
if (!\array_key_exists($name, $this->lock) || $data !== $this->lock[$name]) {
53+
$this->lock[$name] = $data;
54+
$this->changed = true;
55+
}
5456
}
5557

5658
public function remove($name)
5759
{
58-
unset($this->lock[$name]);
59-
$this->changed = true;
60+
if (\array_key_exists($name, $this->lock)) {
61+
unset($this->lock[$name]);
62+
$this->changed = true;
63+
}
6064
}
6165

6266
public function write()

0 commit comments

Comments
 (0)