# New Ticket Created by Steve Fink
# Please include the string: [perl #16855]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org/rt2/Ticket/Display.html?id=16855 >
In tracking down a gc bug, I realized that the current throwaway
implementation of the print op could be replaced with a faster
throwaway implementation that avoids doing a string_to_cstring.
Note that both the original and new implementations are still buggy
with respect to supporting different encodings. I don't know if
printf("%s") is any better than fwrite in terms of at least vaguely
paying attention to your locale or whatever. If so, don't apply it.
(all tests pass)
This patch, like the preceding several, are really just the detritus
resulting from me trying to clean up my local copy wrt to CVS. I will
now revert this change in my local code, and get the change back later
if someone bothers to apply the patch.
-- attachment 1 ------------------------------------------------------
url: http://rt.perl.org/rt2/attach/36044/29166/2d4445/fwrite-print.patch
Index: core.ops
===================================================================
RCS file: /cvs/public/parrot/core.ops,v
retrieving revision 1.203
diff -p -u -r1.203 core.ops
--- core.ops 23 Aug 2002 17:21:38 -0000 1.203
+++ core.ops 29 Aug 2002 19:51:34 -0000
@@ -240,7 +240,7 @@ inline op print(in NUM) {
op print(in STR) {
STRING *s = $1;
if (s && string_length(s)) {
- printf("%s", string_to_cstring(interpreter, (s)));
+ fwrite(s->strstart, s->strlen, 1, stdout);
}
goto NEXT();
}
@@ -249,7 +249,7 @@ op print(in PMC) {
PMC *p = $1;
STRING *s = (p->vtable->get_string(interpreter, p));
if (s) {
- printf("%s", string_to_cstring(interpreter, (s)));
+ fwrite(s->strstart, s->strlen, 1, stdout);
}
goto NEXT();
}
@@ -298,7 +298,7 @@ op print(in INT, in STR) {
default: file = OPCODE_T2PTR(FILE *, $1);
}
if (s && string_length(s)) {
- fprintf(file, "%s", string_to_cstring(interpreter, (s)));
+ fwrite(s->strstart, s->strlen, 1, stdout);
}
goto NEXT();
}
@@ -317,7 +317,7 @@ op print(in INT, in PMC) {
default: file = OPCODE_T2PTR(FILE *, $1);
}
if (s) {
- fprintf(file, "%s", string_to_cstring(interpreter, (s)));
+ fwrite(s->strstart, s->strlen, 1, stdout);
}
goto NEXT();
}