@@ -56,7 +56,7 @@ public function getChanges(): array
56
56
57
57
foreach ($ this ->diff ->getGroupedOpcodes () as $ opcodes ) {
58
58
$ blocks = [];
59
- $ lastTag = null ;
59
+ $ lastTag = 0 ;
60
60
$ lastBlock = 0 ;
61
61
62
62
foreach ($ opcodes as [$ tag , $ i1 , $ i2 , $ j1 , $ j2 ]) {
@@ -88,20 +88,7 @@ public function getChanges(): array
88
88
continue ;
89
89
}
90
90
91
- /**
92
- * @todo By setting option "useIntOpcodes" for the sequence matcher,
93
- * this "if" could be further optimized by using bit operations.
94
- *
95
- * Like this: "if ($tag & (OP_INT_REP | OP_INT_DEL))"
96
- *
97
- * But int tag would be less readable while debugging.
98
- * Also, this would be a BC break for the output of the JSON renderer.
99
- * Is it worth doing?
100
- */
101
- if (
102
- $ tag === SequenceMatcher::OP_REP ||
103
- $ tag === SequenceMatcher::OP_DEL
104
- ) {
91
+ if ($ tag & (SequenceMatcher::OP_REP | SequenceMatcher::OP_DEL )) {
105
92
$ lines = \array_slice ($ old , $ i1 , $ i2 - $ i1 );
106
93
$ lines = $ this ->formatLines ($ lines );
107
94
$ lines = \str_replace (
@@ -113,10 +100,7 @@ public function getChanges(): array
113
100
$ blocks [$ lastBlock ]['old ' ]['lines ' ] += $ lines ;
114
101
}
115
102
116
- if (
117
- $ tag === SequenceMatcher::OP_REP ||
118
- $ tag === SequenceMatcher::OP_INS
119
- ) {
103
+ if ($ tag & (SequenceMatcher::OP_REP | SequenceMatcher::OP_INS )) {
120
104
$ lines = \array_slice ($ new , $ j1 , $ j2 - $ j1 );
121
105
$ lines = $ this ->formatLines ($ lines );
122
106
$ lines = \str_replace (
@@ -167,13 +151,13 @@ protected function renderChangedExtent(AbstractLineRenderer $lineRenderer, strin
167
151
/**
168
152
* Get the default block.
169
153
*
170
- * @param string $tag the operation tag
171
- * @param int $i1 begin index of the diff of the old array
172
- * @param int $j1 begin index of the diff of the new array
154
+ * @param int $tag the operation tag
155
+ * @param int $i1 begin index of the diff of the old array
156
+ * @param int $j1 begin index of the diff of the new array
173
157
*
174
158
* @return array the default block
175
159
*/
176
- protected function getDefaultBlock (string $ tag , int $ i1 , int $ j1 ): array
160
+ protected function getDefaultBlock (int $ tag , int $ i1 , int $ j1 ): array
177
161
{
178
162
return [
179
163
'tag ' => $ tag ,
0 commit comments