Skip to content

Commit 2a98c4a

Browse files
committed
Small refactoring.
1 parent 0d45be9 commit 2a98c4a

File tree

1 file changed

+4
-5
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/str

1 file changed

+4
-5
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/str/StringBuiltins.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -755,26 +755,25 @@ public String translate(String self, PDict table,
755755
return new String(translatedChars);
756756
}
757757

758-
private static String translateFromByteTable(String text, Object table, BytesNodes.ToBytesNode toBytesNode) {
758+
private static String translateFromByteTable(String text, byte[] table) {
759759
byte[] translatedChars = text.getBytes();
760-
byte[] byteTable = toBytesNode.execute(table);
761760
for (int i = 0; i < translatedChars.length; i++) {
762761
byte original = translatedChars[i];
763-
translatedChars[i] = byteTable[original];
762+
translatedChars[i] = table[original];
764763
}
765764
return new String(translatedChars);
766765
}
767766

768767
@Specialization
769768
public String translate(String self, PIBytesLike table,
770769
@Cached("create()") BytesNodes.ToBytesNode getBytesNode) {
771-
return translateFromByteTable(self, table, getBytesNode);
770+
return translateFromByteTable(self, getBytesNode.execute(table));
772771
}
773772

774773
@Specialization
775774
public String translate(String self, PMemoryView table,
776775
@Cached("create()") BytesNodes.ToBytesNode getBytesNode) {
777-
return translateFromByteTable(self, table, getBytesNode);
776+
return translateFromByteTable(self, getBytesNode.execute(table));
778777
}
779778

780779
}

0 commit comments

Comments
 (0)