Skip to content

Inefficient codegen for varargs, openArray #22248

Open
@arnetheduck

Description

@arnetheduck

Description

proc ff(a, b: string) = discard
proc fff(v: varargs[string]) = discard
proc fff2(v: openArray[string]) = discard

proc gggg() =
  let
    a = f()
    b = f()

  ff(a, b)
  fff(a, b)
  fff2([a, b])
N_LIB_PRIVATE N_NIMCALL(void, gggg__testit_12)(void) {
	NimStringDesc* a;
	NimStringDesc* b;
	tyArray__Re75IspeoxXy2oCZHwcRrA T1_;
	tyArray__Re75IspeoxXy2oCZHwcRrA T2_;
	a = f__testit_3();
	b = f__testit_3();
	ff__testit_5(a, b);
	nimZeroMem((void*)T1_, sizeof(tyArray__Re75IspeoxXy2oCZHwcRrA));
	T1_[0] = copyString(a);
	T1_[1] = copyString(b);
	fff__testit_8(T1_, 2);
	nimZeroMem((void*)T2_, sizeof(tyArray__Re75IspeoxXy2oCZHwcRrA));
	T2_[0] = copyString(a);
	T2_[1] = copyString(b);
	fff2__testit_10(T2_, 2);
}

clearly, the copyString is not needed

Nim Version

1.6.12, devel (refc)

Current Output

No response

Expected Output

No response

Possible Solution

No response

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    refcrefc issues

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions