From: Stefan Behnel Date: Wed, 14 Jul 2010 07:42:34 +0000 (+0200) Subject: deploy unicode.encode() optimisation also for 'bytes' provided encodings X-Git-Tag: 0.13.beta0~23 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=50b5656a33b9d365bccf8314babed3937fc634b3;p=cython.git deploy unicode.encode() optimisation also for 'bytes' provided encodings --- diff --git a/Cython/Compiler/Optimize.py b/Cython/Compiler/Optimize.py index 4a77e694..378b88a5 100644 --- a/Cython/Compiler/Optimize.py +++ b/Cython/Compiler/Optimize.py @@ -2202,6 +2202,10 @@ class OptimizeBuiltinCalls(Visitor.EnvTransform): encoding = encoding_node.value encoding_node = ExprNodes.BytesNode(encoding_node.pos, value=encoding, type=PyrexTypes.c_char_ptr_type) + elif encoding_node.type is Builtin.bytes_type: + encoding = None + encoding_node = encoding_node.coerce_to( + PyrexTypes.c_char_ptr_type, self.current_env()) elif encoding_node.type.is_string: encoding = None else: @@ -2224,6 +2228,10 @@ class OptimizeBuiltinCalls(Visitor.EnvTransform): error_handling_node = ExprNodes.BytesNode( error_handling_node.pos, value=error_handling, type=PyrexTypes.c_char_ptr_type) + elif error_handling_node.type is Builtin.bytes_type: + error_handling = None + error_handling_node = error_handling_node.coerce_to( + PyrexTypes.c_char_ptr_type, self.current_env()) elif error_handling_node.type.is_string: error_handling = None else: