[Jython-checkins] jython: Use cached newlines and spaces where possible.
frank.wierzbicki
jython-checkins at python.org
Wed May 18 02:53:30 CEST 2011
http://hg.python.org/jython/rev/a51c53c858b6
changeset: 6217:a51c53c858b6
user: Frank Wierzbicki <fwierzbicki at gmail.com>
date: Tue May 17 14:32:31 2011 -0700
summary:
Use cached newlines and spaces where possible.
files:
src/org/python/core/Py.java | 2 +-
src/org/python/core/__builtin__.java | 25 ++++++++++-----
2 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/src/org/python/core/Py.java b/src/org/python/core/Py.java
--- a/src/org/python/core/Py.java
+++ b/src/org/python/core/Py.java
@@ -85,7 +85,7 @@
/** A Python string containing ' ' **/
public static PyString Space;
/** A Python unicode string containing ' ' **/
- public static PyString UnicodeSpace;
+ public static PyUnicode UnicodeSpace;
/** Set if the type object is dynamically allocated */
public static long TPFLAGS_HEAPTYPE = 1L << 9;
/** Set if the type allows subclassing */
diff --git a/src/org/python/core/__builtin__.java b/src/org/python/core/__builtin__.java
--- a/src/org/python/core/__builtin__.java
+++ b/src/org/python/core/__builtin__.java
@@ -1370,12 +1370,6 @@
if (values.length == 0) {
out.println(useUnicode);
} else {
- if (sep == null) {
- sep = " ";
- }
- if (end == null) {
- end = "\n";
- }
if (!useUnicode) {
for (PyObject value: values) {
if (value instanceof PyUnicode) {
@@ -1384,9 +1378,22 @@
}
}
}
- out.print(values,
- useUnicode ? Py.newUnicode(sep) : Py.newString(sep),
- useUnicode ? Py.newUnicode(end) : Py.newString(end));
+
+ PyObject sepObject;
+ if (sep == null) {
+ sepObject = useUnicode ? Py.UnicodeSpace : Py.Space;
+ } else {
+ sepObject = useUnicode ? Py.newUnicode(sep) : Py.newString(sep);
+ }
+
+ PyObject endObject;
+ if (end == null) {
+ endObject = useUnicode ? Py.UnicodeNewline : Py.Newline;
+ } else {
+ endObject = useUnicode ? Py.newUnicode(end) : Py.newString(end);
+ }
+
+ out.print(values, sepObject, endObject);
}
return Py.None;
}
--
Repository URL: http://hg.python.org/jython
More information about the Jython-checkins
mailing list