@@ -56,7 +56,7 @@ public function getChanges(): array
5656
5757 foreach ($ this ->diff ->getGroupedOpcodes () as $ opcodes ) {
5858 $ blocks = [];
59- $ lastTag = null ;
59+ $ lastTag = 0 ;
6060 $ lastBlock = 0 ;
6161
6262 foreach ($ opcodes as [$ tag , $ i1 , $ i2 , $ j1 , $ j2 ]) {
@@ -88,20 +88,7 @@ public function getChanges(): array
8888 continue ;
8989 }
9090
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 )) {
10592 $ lines = \array_slice ($ old , $ i1 , $ i2 - $ i1 );
10693 $ lines = $ this ->formatLines ($ lines );
10794 $ lines = \str_replace (
@@ -113,10 +100,7 @@ public function getChanges(): array
113100 $ blocks [$ lastBlock ]['old ' ]['lines ' ] += $ lines ;
114101 }
115102
116- if (
117- $ tag === SequenceMatcher::OP_REP ||
118- $ tag === SequenceMatcher::OP_INS
119- ) {
103+ if ($ tag & (SequenceMatcher::OP_REP | SequenceMatcher::OP_INS )) {
120104 $ lines = \array_slice ($ new , $ j1 , $ j2 - $ j1 );
121105 $ lines = $ this ->formatLines ($ lines );
122106 $ lines = \str_replace (
@@ -167,13 +151,13 @@ protected function renderChangedExtent(AbstractLineRenderer $lineRenderer, strin
167151 /**
168152 * Get the default block.
169153 *
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
173157 *
174158 * @return array the default block
175159 */
176- protected function getDefaultBlock (string $ tag , int $ i1 , int $ j1 ): array
160+ protected function getDefaultBlock (int $ tag , int $ i1 , int $ j1 ): array
177161 {
178162 return [
179163 'tag ' => $ tag ,
0 commit comments