Skip to content

Commit

Permalink
inline++
Browse files Browse the repository at this point in the history
  • Loading branch information
felipensp committed Nov 24, 2024
1 parent 2dddbc5 commit a6bf38b
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions vlib/v/gen/c/auto_eq_methods.v
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ fn (mut g Gen) gen_sumtype_equality_fn(left_type ast.Type) string {
right_typ := g.read_field(left_type, '_typ', 'b')

mut fn_builder := strings.new_builder(512)
fn_builder.writeln('static bool ${ptr_styp}_sumtype_eq(${ptr_styp} a, ${ptr_styp} b) {')
fn_builder.writeln('static inline bool ${ptr_styp}_sumtype_eq(${ptr_styp} a, ${ptr_styp} b) {')
fn_builder.writeln('\tif (${left_typ} != ${right_typ}) { return false; }')
fn_builder.writeln('\tif (${left_typ} == ${right_typ} && ${right_typ} == 0) { return true; } // uninitialized')
for typ in info.variants {
Expand Down Expand Up @@ -190,7 +190,7 @@ fn (mut g Gen) gen_struct_equality_fn(left_type ast.Type) string {
defer {
g.auto_fn_definitions << fn_builder.str()
}
fn_builder.writeln('static bool ${fn_name}_struct_eq(${ptr_styp} a, ${ptr_styp} b) {')
fn_builder.writeln('static inline bool ${fn_name}_struct_eq(${ptr_styp} a, ${ptr_styp} b) {')

// overloaded
if left.sym.has_method('==') {
Expand Down Expand Up @@ -290,7 +290,7 @@ fn (mut g Gen) gen_alias_equality_fn(left_type ast.Type) string {
g.definitions.writeln('static bool ${ptr_styp}_alias_eq(${ptr_styp} a, ${ptr_styp} b); // auto')

mut fn_builder := strings.new_builder(512)
fn_builder.writeln('static bool ${ptr_styp}_alias_eq(${ptr_styp} a, ${ptr_styp} b) {')
fn_builder.writeln('static inline bool ${ptr_styp}_alias_eq(${ptr_styp} a, ${ptr_styp} b) {')

is_option := left.typ.has_flag(.option)

Expand Down Expand Up @@ -351,7 +351,7 @@ fn (mut g Gen) gen_array_equality_fn(left_type ast.Type) string {
g.definitions.writeln('static bool ${ptr_styp}_arr_eq(${ptr_styp} a, ${ptr_styp} b); // auto')

mut fn_builder := strings.new_builder(512)
fn_builder.writeln('static bool ${ptr_styp}_arr_eq(${ptr_styp} a, ${ptr_styp} b) {')
fn_builder.writeln('static inline bool ${ptr_styp}_arr_eq(${ptr_styp} a, ${ptr_styp} b) {')

left_len := g.read_field(left_type, 'len', 'a')
right_len := g.read_field(left_type, 'len', 'b')
Expand Down Expand Up @@ -432,7 +432,7 @@ fn (mut g Gen) gen_fixed_array_equality_fn(left_type ast.Type) string {
right := if left_type.has_flag(.option) { 'b.data' } else { 'b' }

mut fn_builder := strings.new_builder(512)
fn_builder.writeln('static bool ${ptr_styp}_arr_eq(${ptr_styp} a, ${ptr_styp} b) {')
fn_builder.writeln('static inline bool ${ptr_styp}_arr_eq(${ptr_styp} a, ${ptr_styp} b) {')
fn_builder.writeln('\tfor (int i = 0; i < ${size}; ++i) {')
// compare every pair of elements of the two fixed arrays
if elem.sym.kind == .string {
Expand Down Expand Up @@ -494,7 +494,7 @@ fn (mut g Gen) gen_map_equality_fn(left_type ast.Type) string {
b := if left.typ.has_flag(.option) { g.read_map_from_option(left.typ, 'b') } else { '&b' }

mut fn_builder := strings.new_builder(512)
fn_builder.writeln('static bool ${ptr_styp}_map_eq(${ptr_styp} a, ${ptr_styp} b) {')
fn_builder.writeln('static inline bool ${ptr_styp}_map_eq(${ptr_styp} a, ${ptr_styp} b) {')
fn_builder.writeln('\tif (${left_len} != ${right_len}) {')
fn_builder.writeln('\t\treturn false;')
fn_builder.writeln('\t}')
Expand Down Expand Up @@ -587,7 +587,7 @@ fn (mut g Gen) gen_interface_equality_fn(left_type ast.Type) string {
right_arg := g.read_field(left_type, '_typ', 'b')

fn_builder.writeln('static int v_typeof_interface_idx_${idx_fn}(int sidx); // for auto eq method')
fn_builder.writeln('static bool ${fn_name}_interface_eq(${ptr_styp} a, ${ptr_styp} b) {')
fn_builder.writeln('static inline bool ${fn_name}_interface_eq(${ptr_styp} a, ${ptr_styp} b) {')
fn_builder.writeln('\tif (${left_arg} == ${right_arg}) {')
fn_builder.writeln('\t\tint idx = v_typeof_interface_idx_${idx_fn}(${left_arg});')
if info is ast.Interface {
Expand Down

0 comments on commit a6bf38b

Please sign in to comment.