def _ModifiedSizer(compute_value_size, modify_value):
def SpecificSizer(field_number, is_repeated, is_packed):<EOL><INDENT>tag_size = _TagSize(field_number)<EOL>if is_packed:<EOL><INDENT>local_VarintSize = _VarintSize<EOL>def PackedFieldSize(value):<EOL><INDENT>result = <NUM_LIT:0><EOL>for element in value:<EOL><INDENT>result += compute_value_size(modify_value(element))<EOL><DEDENT>return result + local_VarintSize(result) + tag_size<EOL><DEDENT>return PackedFieldSize<EOL><DEDENT>elif is_repeated:<EOL><INDENT>def RepeatedFieldSize(value):<EOL><INDENT>result = tag_size * len(value)<EOL>for element in value:<EOL><INDENT>result += compute_value_size(modify_value(element))<EOL><DEDENT>return result<EOL><DEDENT>return RepeatedFieldSize<EOL><DEDENT>else:<EOL><INDENT>def FieldSize(value):<EOL><INDENT>return tag_size + compute_value_size(modify_value(value))<EOL><DEDENT>return FieldSize<EOL><DEDENT><DEDENT>return SpecificSizer<EOL>
Like SimpleSizer, but modify_value is invoked on each value before it is
    passed to compute_value_size.  modify_value is typically ZigZagEncode.