@@ -25,10 +25,10 @@ abstract class AbstractHtml extends AbstractRenderer
2525 * @var array array of the different opcode tags and how they map to the HTML class
2626 */
2727 const TAG_CLASS_MAP = [
28- SequenceMatcher::OPCODE_DELETE => 'del ' ,
29- SequenceMatcher::OPCODE_EQUAL => 'eq ' ,
30- SequenceMatcher::OPCODE_INSERT => 'ins ' ,
31- SequenceMatcher::OPCODE_REPLACE => 'rep ' ,
28+ SequenceMatcher::OP_DEL => 'del ' ,
29+ SequenceMatcher::OP_EQ => 'eq ' ,
30+ SequenceMatcher::OP_INS => 'ins ' ,
31+ SequenceMatcher::OP_REP => 'rep ' ,
3232 ];
3333
3434 /**
@@ -61,7 +61,7 @@ public function getChanges(): array
6161
6262 foreach ($ opcodes as [$ tag , $ i1 , $ i2 , $ j1 , $ j2 ]) {
6363 if (
64- $ tag === SequenceMatcher::OPCODE_REPLACE &&
64+ $ tag === SequenceMatcher::OP_REP &&
6565 $ i2 - $ i1 === $ j2 - $ j1
6666 ) {
6767 for ($ i = 0 ; $ i < $ i2 - $ i1 ; ++$ i ) {
@@ -76,7 +76,7 @@ public function getChanges(): array
7676
7777 $ lastTag = $ tag ;
7878
79- if ($ tag === SequenceMatcher::OPCODE_EQUAL ) {
79+ if ($ tag === SequenceMatcher::OP_EQ ) {
8080 if (!empty ($ lines = \array_slice ($ a , $ i1 , ($ i2 - $ i1 )))) {
8181 $ formattedLines = $ this ->formatLines ($ lines );
8282
@@ -87,9 +87,19 @@ public function getChanges(): array
8787 continue ;
8888 }
8989
90+ /**
91+ * @todo By setting option "useIntOpcodes" for the sequence matcher,
92+ * this "if" could be further optimized by using bit operations.
93+ *
94+ * Like this: "if ($tag & (OP_INT_REP | OP_INT_DEL))"
95+ *
96+ * But int tag would be less readable while debugging.
97+ * Also, this would be a BC break for the output of the JSON renderer.
98+ * Is it worth doing?
99+ */
90100 if (
91- $ tag === SequenceMatcher::OPCODE_REPLACE ||
92- $ tag === SequenceMatcher::OPCODE_DELETE
101+ $ tag === SequenceMatcher::OP_REP ||
102+ $ tag === SequenceMatcher::OP_DEL
93103 ) {
94104 $ lines = \array_slice ($ a , $ i1 , ($ i2 - $ i1 ));
95105 $ lines = $ this ->formatLines ($ lines );
@@ -98,12 +108,13 @@ public function getChanges(): array
98108 RendererConstant::HTML_CLOSURES_DEL ,
99109 $ lines
100110 );
111+
101112 $ blocks [$ lastBlock ]['base ' ]['lines ' ] += $ lines ;
102113 }
103114
104115 if (
105- $ tag === SequenceMatcher::OPCODE_REPLACE ||
106- $ tag === SequenceMatcher::OPCODE_INSERT
116+ $ tag === SequenceMatcher::OP_REP ||
117+ $ tag === SequenceMatcher::OP_INS
107118 ) {
108119 $ lines = \array_slice ($ b , $ j1 , ($ j2 - $ j1 ));
109120 $ lines = $ this ->formatLines ($ lines );
@@ -112,6 +123,7 @@ public function getChanges(): array
112123 RendererConstant::HTML_CLOSURES_INS ,
113124 $ lines
114125 );
126+
115127 $ blocks [$ lastBlock ]['changed ' ]['lines ' ] += $ lines ;
116128 }
117129 }
0 commit comments