topazproject / topaz

A high performance ruby, written in RPython
topazruby.com
BSD 3-Clause "New" or "Revised" License
1k stars 84 forks source link

String#<< doesn't do proper type checks #325

Open judofyr opened 11 years ago

judofyr commented 11 years ago

https://github.com/topazproject/topaz/blob/cdf71e9f5a2b948e1d29755055cc2fe7f91fa1f1/topaz/objects/stringobject.py#L370

    @classdef.method("<<")
    def method_lshift(self, space, w_other):
        assert isinstance(w_other, W_StringObject)
        self.extend(space, w_other)
        return self

This would make Topaz much faster in String-related benchmarks (e.g. https://github.com/timfel/topaz_bmpstreaming_demo)

judofyr commented 11 years ago

Same for Array#<< (which is used in the benchmark that you ship with).

timfel commented 11 years ago

These methods should use argument coercion.