Skip to content

Commit

Permalink
Improve ordering of impls
Browse files Browse the repository at this point in the history
  • Loading branch information
ericglau committed Nov 28, 2023
1 parent b593868 commit a75b224
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions packages/core-cairo/src/print.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,18 +97,16 @@ function printComponentDeclarations(contract: Contract) {
}

function printImpls(contract: Contract) {
const lines = [];
for (const component of contract.components) {
for (const impl of component.impls) {
lines.push(...printImpl(impl, false));
}
if (component.internalImpl !== undefined) {
lines.push(...printImpl(component.internalImpl, true));
}
}
return lines;
const externalImpls = contract.components.flatMap(c => c.impls);
const internalImpls = contract.components.flatMap(c => c.internalImpl ? [c.internalImpl] : []);

return [
...externalImpls.flatMap(impl => printImpl(impl)),
...internalImpls.flatMap(impl => printImpl(impl, true))
];
}


function printImpl(impl: Impl, internal = false) {
const lines = [];
if (!internal) {
Expand Down

0 comments on commit a75b224

Please sign in to comment.