Skip to content

Commit 5eed718

Browse files
committed
Rename StringUtils#format to formatJString
1 parent ec1e9c3 commit 5eed718

26 files changed

+52
-52
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/TimeModuleBuiltins.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -575,15 +575,15 @@ protected ArgumentClinicProvider getArgumentClinic() {
575575
}
576576

577577
private static String format(String format, int arg1) {
578-
return PythonUtils.format(format, arg1);
578+
return PythonUtils.formatJString(format, arg1);
579579
}
580580

581581
private static String dateFormat(int[] date) {
582-
return PythonUtils.format("%02d/%02d/", date[TM_MON], date[TM_MDAY]) + truncYear(date[TM_YEAR]);
582+
return PythonUtils.formatJString("%02d/%02d/", date[TM_MON], date[TM_MDAY]) + truncYear(date[TM_YEAR]);
583583
}
584584

585585
private static String timeFormat(int[] date) {
586-
return PythonUtils.format("%02d:%02d:%02d", date[TM_HOUR], date[TM_MIN], date[TM_SEC]);
586+
return PythonUtils.formatJString("%02d:%02d:%02d", date[TM_HOUR], date[TM_MIN], date[TM_SEC]);
587587
}
588588

589589
protected static int[] checkStructtime(VirtualFrame frame, PTuple time,
@@ -1020,7 +1020,7 @@ protected static TruffleString format(String format, int[] tm, TruffleString.Fro
10201020
assert tm[TM_MON] > 0;
10211021
String day = WDAY_NAME[tm[TM_WDAY]];
10221022
String month = MON_NAME[tm[TM_MON]];
1023-
String str = PythonUtils.format(format, day, month, tm[TM_MDAY], tm[TM_HOUR], tm[TM_MIN], tm[TM_SEC], tm[TM_YEAR]);
1023+
String str = PythonUtils.formatJString(format, day, month, tm[TM_MDAY], tm[TM_HOUR], tm[TM_MIN], tm[TM_SEC], tm[TM_YEAR]);
10241024
return fromJavaStringNode.execute(str, TS_ENCODING);
10251025
}
10261026
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextBuiltins.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1715,7 +1715,7 @@ int doCachedDomainIdx(VirtualFrame frame, @SuppressWarnings("unused") long domai
17151715
cApiContext.getTraceMallocDomain(cachedDomainIdx).track(pointerObject, size);
17161716
cApiContext.increaseMemoryPressure(frame, getThreadStateNode, this, size);
17171717
if (LOGGER.isLoggable(Level.FINE)) {
1718-
LOGGER.fine(() -> PythonUtils.format("Tracking memory (size: %d): %s", size, CApiContext.asHex(pointerObject)));
1718+
LOGGER.fine(() -> PythonUtils.formatJString("Tracking memory (size: %d): %s", size, CApiContext.asHex(pointerObject)));
17191719
}
17201720
return 0;
17211721
}
@@ -1746,7 +1746,7 @@ int doCachedDomainIdx(@SuppressWarnings("unused") long domain, Object pointerObj
17461746
long trackedMemorySize = cApiContext.getTraceMallocDomain(cachedDomainIdx).untrack(pointerObject);
17471747
cApiContext.reduceMemoryPressure(trackedMemorySize);
17481748
if (LOGGER.isLoggable(Level.FINE)) {
1749-
LOGGER.fine(() -> PythonUtils.format("Untracking memory (size: %d): %s", trackedMemorySize, CApiContext.asHex(pointerObject)));
1749+
LOGGER.fine(() -> PythonUtils.formatJString("Untracking memory (size: %d): %s", trackedMemorySize, CApiContext.asHex(pointerObject)));
17501750
}
17511751
return 0;
17521752
}
@@ -1821,7 +1821,7 @@ abstract static class PyTruffleGcUntrack extends PyTruffleGcTracingNode {
18211821

18221822
@Override
18231823
protected void trace(PythonContext context, Object ptr, Reference ref, TruffleString className) {
1824-
LOGGER.fine(() -> PythonUtils.format("Untracking container object at %s", CApiContext.asHex(ptr)));
1824+
LOGGER.fine(() -> PythonUtils.formatJString("Untracking container object at %s", CApiContext.asHex(ptr)));
18251825
context.getCApiContext().untrackObject(ptr, ref, className);
18261826
}
18271827
}
@@ -1833,7 +1833,7 @@ abstract static class PyTruffleGcTrack extends PyTruffleGcTracingNode {
18331833

18341834
@Override
18351835
protected void trace(PythonContext context, Object ptr, Reference ref, TruffleString className) {
1836-
LOGGER.fine(() -> PythonUtils.format("Tracking container object at %s", CApiContext.asHex(ptr)));
1836+
LOGGER.fine(() -> PythonUtils.formatJString("Tracking container object at %s", CApiContext.asHex(ptr)));
18371837
context.getCApiContext().trackObject(ptr, ref, className);
18381838
}
18391839
}
@@ -1881,7 +1881,7 @@ static int doNativeWrapperLong(Object ptr, long size,
18811881
}
18821882
AllocInfo allocLocation = cApiContext.traceFree(CApiContext.asPointer(ptr, lib), ref, null);
18831883
if (allocLocation != null) {
1884-
LOGGER.finer(() -> PythonUtils.format("Freeing pointer (size: %d): %s", allocLocation.size, CApiContext.asHex(ptr)));
1884+
LOGGER.finer(() -> PythonUtils.formatJString("Freeing pointer (size: %d): %s", allocLocation.size, CApiContext.asHex(ptr)));
18851885

18861886
if (traceNativeMemoryCalls) {
18871887
Reference left = allocLocation.allocationSite;
@@ -1892,13 +1892,13 @@ static int doNativeWrapperLong(Object ptr, long size,
18921892
}
18931893
if (pyFrame != null) {
18941894
final PFrame f = pyFrame;
1895-
LOGGER.finer(() -> PythonUtils.format("Free'd pointer was allocated at: %s", f.getTarget()));
1895+
LOGGER.finer(() -> PythonUtils.formatJString("Free'd pointer was allocated at: %s", f.getTarget()));
18961896
}
18971897
}
18981898
}
18991899
} else {
19001900
assert isLoggable;
1901-
LOGGER.finer(() -> PythonUtils.format("Freeing pointer: %s", CApiContext.asHex(ptr)));
1901+
LOGGER.finer(() -> PythonUtils.formatJString("Freeing pointer: %s", CApiContext.asHex(ptr)));
19021902
}
19031903
}
19041904
return 0;
@@ -1945,7 +1945,7 @@ int trace(Object ptr, Object classNameObj,
19451945
PythonContext context = getContext();
19461946
Object primitivePtr = CApiContext.asPointer(ptr, ptrLib);
19471947
context.getCApiContext().traceStaticMemory(primitivePtr, null, className);
1948-
LOGGER.fine(() -> PythonUtils.format("Initializing native type %s (ptr = %s)", className, CApiContext.asHex(primitivePtr)));
1948+
LOGGER.fine(() -> PythonUtils.formatJString("Initializing native type %s (ptr = %s)", className, CApiContext.asHex(primitivePtr)));
19491949
return 0;
19501950
}
19511951
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/cext/PythonCextObjectBuiltins.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,7 @@ int doGeneric(Object ptrObject) {
722722
*/
723723
boolean traceNativeMemory = context.getOption(PythonOptions.TraceNativeMemory);
724724
if (pointsToHandleSpace && !isValidHandle || traceNativeMemory && !isWrapper && !cApiContext.isAllocated(ptrObject)) {
725-
stderr.println(PythonUtils.format("<object at %s is freed>", CApiContext.asPointer(ptrObject, lib)));
725+
stderr.println(PythonUtils.formatJString("<object at %s is freed>", CApiContext.asPointer(ptrObject, lib)));
726726
stderr.flush();
727727
return 0;
728728
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ctypes/CArgObjectBuiltins.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,31 +111,31 @@ TruffleString doit(PyCArgObject self,
111111
case 'L':
112112
case 'q': // TODO big int
113113
case 'Q': // TODO big int
114-
ret = PythonUtils.format("<cparam '%c' (%d)>", self.tag, self.value);
114+
ret = PythonUtils.formatJString("<cparam '%c' (%d)>", self.tag, self.value);
115115
break;
116116
case 'd':
117117
case 'f': {
118-
ret = PythonUtils.format("<cparam '%c' (%f)>", self.tag, self.value);
118+
ret = PythonUtils.formatJString("<cparam '%c' (%f)>", self.tag, self.value);
119119
break;
120120
}
121121
case 'c':
122122
byte[] bytes = ((ByteArrayStorage) self.value.ptr).value;
123123
if (isLiteralChar((char) bytes[0])) {
124-
ret = PythonUtils.format("<cparam '%c' ('%c')>", self.tag, self.value);
124+
ret = PythonUtils.formatJString("<cparam '%c' ('%c')>", self.tag, self.value);
125125
} else {
126-
ret = PythonUtils.format("<cparam '%c' ('\\x%02x')>", self.tag, PythonAbstractObject.systemHashCode(self.value));
126+
ret = PythonUtils.formatJString("<cparam '%c' ('\\x%02x')>", self.tag, PythonAbstractObject.systemHashCode(self.value));
127127
}
128128
break;
129129
case 'z':
130130
case 'Z':
131131
case 'P':
132-
ret = PythonUtils.format("<cparam '%c' 0x%x>", self.tag, PythonAbstractObject.systemHashCode(self.value));
132+
ret = PythonUtils.formatJString("<cparam '%c' 0x%x>", self.tag, PythonAbstractObject.systemHashCode(self.value));
133133
break;
134134
default:
135135
if (isLiteralChar(self.tag)) {
136-
ret = PythonUtils.format("<cparam '%c' at 0x%x>", self.tag, PythonAbstractObject.systemHashCode(self));
136+
ret = PythonUtils.formatJString("<cparam '%c' at 0x%x>", self.tag, PythonAbstractObject.systemHashCode(self));
137137
} else {
138-
ret = PythonUtils.format("<cparam 0x%02x at 0x%x>", self.tag, PythonAbstractObject.systemHashCode(self));
138+
ret = PythonUtils.formatJString("<cparam 0x%02x at 0x%x>", self.tag, PythonAbstractObject.systemHashCode(self));
139139
}
140140
}
141141
return fromJavaStringNode.execute(ret, TS_ENCODING);

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/PythonAbstractNativeObject.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public boolean equalsProfiled(Object obj, ValueProfile profile) {
132132
@Override
133133
public String toString() {
134134
CompilerAsserts.neverPartOfCompilation();
135-
return PythonUtils.format("PythonAbstractNativeObject(%s)", object);
135+
return PythonUtils.formatJString("PythonAbstractNativeObject(%s)", object);
136136
}
137137

138138
@ExportMessage

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/PythonNativeClass.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public interface PythonNativeClass extends PythonAbstractClass {
5757
Object getPtr();
5858

5959
default String getName() {
60-
return PythonUtils.format("PythonNativeClass(%s)", getPtr());
60+
return PythonUtils.formatJString("PythonNativeClass(%s)", getPtr());
6161
}
6262

6363
static boolean isInstance(Object object) {

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/PythonNativeVoidPtr.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,6 @@ public int compareTo(Object o) {
9191
@Override
9292
public String toString() {
9393
CompilerAsserts.neverPartOfCompilation();
94-
return PythonUtils.format("PythonNativeVoidPtr(%s)", object);
94+
return PythonUtils.formatJString("PythonNativeVoidPtr(%s)", object);
9595
}
9696
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CApiContext.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ public PythonAbstractNativeObject getPythonNativeObject(Object nativePtr, Condit
599599
}
600600
return createPythonAbstractNativeObject(nativePtr, addRefCntNode, steal, attachLLVMTypeNode);
601601
} else {
602-
LOGGER.warning(() -> PythonUtils.format("cannot associate a native object reference to %s because reference count is corrupted", CApiContext.asHex(nativePtr)));
602+
LOGGER.warning(() -> PythonUtils.formatJString("cannot associate a native object reference to %s because reference count is corrupted", CApiContext.asHex(nativePtr)));
603603
}
604604
return new PythonAbstractNativeObject(nativePtr);
605605
}
@@ -658,9 +658,9 @@ public AllocInfo traceFree(Object ptr, @SuppressWarnings("unused") PFrame.Refere
658658
AllocInfo allocatedValue = allocatedNativeMemory.remove(ptr);
659659
Object freedValue = freedNativeMemory.put(ptr, allocatedValue);
660660
if (freedValue != null) {
661-
LOGGER.severe(PythonUtils.format("freeing memory that was already free'd %s (double-free)", asHex(ptr)));
661+
LOGGER.severe(PythonUtils.formatJString("freeing memory that was already free'd %s (double-free)", asHex(ptr)));
662662
} else if (allocatedValue == null) {
663-
LOGGER.info(PythonUtils.format("freeing non-allocated memory %s (maybe a double-free or we didn't trace the allocation)", asHex(ptr)));
663+
LOGGER.info(PythonUtils.formatJString("freeing non-allocated memory %s (maybe a double-free or we didn't trace the allocation)", asHex(ptr)));
664664
}
665665
return allocatedValue;
666666
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CExtNodes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3477,7 +3477,7 @@ Object doGeneric(TruffleString f, Object vaList) {
34773477
} else {
34783478
value = System.identityHashCode(ptr);
34793479
}
3480-
result.append(PythonUtils.format("0x%x", value));
3480+
result.append(PythonUtils.formatJString("0x%x", value));
34813481
vaArgIdx++;
34823482
valid = true;
34833483
break;

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/DynamicObjectNativeWrapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1817,7 +1817,7 @@ public static DynamicObjectNativeWrapper wrapNewRef(PythonAbstractObject obj, Co
18171817
public String toString() {
18181818
CompilerAsserts.neverPartOfCompilation();
18191819
PythonNativeWrapperLibrary lib = PythonNativeWrapperLibrary.getUncached();
1820-
return PythonUtils.format("PythonObjectNativeWrapper(%s, isNative=%s)", lib.getDelegate(this), lib.isNative(this));
1820+
return PythonUtils.formatJString("PythonObjectNativeWrapper(%s, isNative=%s)", lib.getDelegate(this), lib.isNative(this));
18211821
}
18221822

18231823
@ExportMessage

0 commit comments

Comments
 (0)