Commit e368cf9b authored by Stefan Behnel's avatar Stefan Behnel

do not optimise len(str) as it doesn't map to a simple C-API function, small cleanup

parent fa0a8e3a
...@@ -1506,7 +1506,6 @@ class OptimizeBuiltinCalls(Visitor.EnvTransform): ...@@ -1506,7 +1506,6 @@ class OptimizeBuiltinCalls(Visitor.EnvTransform):
_map_to_capi_len_function = { _map_to_capi_len_function = {
Builtin.unicode_type : "PyUnicode_GET_SIZE", Builtin.unicode_type : "PyUnicode_GET_SIZE",
Builtin.str_type : "Py_SIZE", # works in Py2 and Py3
Builtin.bytes_type : "PyBytes_GET_SIZE", Builtin.bytes_type : "PyBytes_GET_SIZE",
Builtin.list_type : "PyList_GET_SIZE", Builtin.list_type : "PyList_GET_SIZE",
Builtin.tuple_type : "PyTuple_GET_SIZE", Builtin.tuple_type : "PyTuple_GET_SIZE",
...@@ -1535,7 +1534,6 @@ class OptimizeBuiltinCalls(Visitor.EnvTransform): ...@@ -1535,7 +1534,6 @@ class OptimizeBuiltinCalls(Visitor.EnvTransform):
cfunc_name = self._map_to_capi_len_function(arg.type) cfunc_name = self._map_to_capi_len_function(arg.type)
if cfunc_name is None: if cfunc_name is None:
return node return node
if not arg.is_literal:
arg = arg.as_none_safe_node( arg = arg.as_none_safe_node(
"object of type 'NoneType' has no len()") "object of type 'NoneType' has no len()")
new_node = ExprNodes.PythonCapiCallNode( new_node = ExprNodes.PythonCapiCallNode(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment