<s> from pypy . rpython . rbuilder import AbstractStringBuilderRepr <EOL> from pypy . rpython . ootypesystem import ootype <EOL> from pypy . rpython . ootypesystem . rstr import string_repr , char_repr , unicode_repr , unichar_repr <EOL> MAX = <NUM_LIT:16> * <NUM_LIT> * <NUM_LIT> <EOL> class BaseBuilderRepr ( AbstractStringBuilderRepr ) : <EOL> @ classmethod <EOL> def ll_new ( cls , init_size ) : <EOL> if init_size < <NUM_LIT:0> or init_size > MAX : <EOL> init_size = MAX <EOL> return ootype . new ( cls . lowleveltype ) <EOL> @ staticmethod <EOL> def ll_append_char ( builder , char ) : <EOL> builder . ll_append_char ( char ) <EOL> @ staticmethod <EOL> def ll_append ( builder , string ) : <EOL> builder . ll_append ( string ) <EOL> @ staticmethod <EOL> def ll_append_slice ( builder , string , start , end ) : <EOL> for i in range ( start , end ) : <EOL> builder . ll_append_char ( string . ll_stritem_nonneg ( i ) ) <EOL> @ staticmethod <EOL> def ll_append_multiple_char ( builder , char , times ) : <EOL> for i in range ( times ) : <EOL> builder . ll_append_char ( char ) <EOL> @ staticmethod <EOL> def ll_build ( builder ) : <EOL> return builder . ll_build ( ) <EOL> class StringBuilderRepr ( BaseBuilderRepr ) : <EOL> lowleveltype = ootype . StringBuilder <EOL> string_repr = string_repr <EOL> char_repr = char_repr <EOL> class UnicodeBuilderRepr ( BaseBuilderRepr ) : <EOL> lowleveltype = ootype . UnicodeBuilder <EOL> string_repr = unicode_repr <EOL> char_repr = unichar_repr <EOL> stringbuilder_repr = StringBuilderRepr ( ) <EOL> unicodebuilder_repr = UnicodeBuilderRepr ( ) </s>
