[MDSAL-84] Binding spec v1: auto generated code by YANGTOOLS could be more efficient. Created: 07/May/15  Updated: 09/Mar/18  Resolved: 13/Feb/17

Status: Resolved
Project: mdsal
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Improvement
Reporter: chenguohai Assignee: Jakub Toth
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: All
Platform: All
URL: https://ask.opendaylight.org/question/3617/there-should-be-some-improvement-about-the-auto-generated-codes-from-yangtools/



 Description   

I am reading the code under ALTO@ODL. And here are my two comments.

1:File named ‘AltoProviderImplBuilder’under alto-provider/……./modules/module/configuration :in function named 'toString',first is defined to judge a common should be inserted, i recommend writting as following

@Override
public java.lang.String toString() {
java.lang.StringBuilder builder = new java.lang.StringBuilder ("AltoProviderImpl [");
//boolean first = true;

if (_dataBroker != null) {
//if (first)

{ // first = false; //} else { // builder.append(", "); //}
builder.append("_dataBroker=");
builder.append(_dataBroker);
builder.append(", ");//new added

}
if (_rpcRegistry != null) {
//if (first) { // first = false; //}

else

{ // builder.append(", "); //}

builder.append("_rpcRegistry=");
builder.append(_rpcRegistry);
builder.append(", ");//new added

}
//if (first)

{ // first = false; //}

else

{ // builder.append(", "); //}

builder.append("augmentation=");
builder.append(augmentation.values());
return builder.append(']').toString();
}
}
Fewer judgement, fewer jumpes and simplified, consistent code,Make sense. There are similar something in file named RpcRegistryBuilder.java under alto-provider/……../modules/module/configuration/alto/provider/impl

BTW,could anyone tell me who is responsible for the improvements



 Comments   
Comment by chenguohai [ 07/May/15 ]

this is not a major problem,but if we could make it more efficient.

Comment by Tony Tkacik [ 07/May/15 ]

If you have some time you may want to improve, otherwise this will be picked-up by someone from yangtools / community.

Comment by chenguohai [ 07/May/15 ]

(In reply to Tony Tkacik from comment #2)
> If you have some time you may want to improve, otherwise this will be
> picked-up by someone from yangtools / community.

let expert do it ,i do not have time.Thanks.
i am occupied by reviewing ALTO code.

Comment by Robert Varga [ 08/Sep/15 ]

This needs to be translated to the builder template. I believe the individual entries are emitted in a loop, where the first two include an additional condition – hence the duplicate lines.

In order to implement this, the generator needs to perform look-ahead, e.g. it needs to understand that a following entry will definitely be emitted. As things stand this is always true for augmentable types, but that can actually change in future – augmentations are empty most of the time, so it may make sense to print them out only if they are non-empty.

In any case this code has moved to the MD-SAL project, so this issue should live there, too.

Comment by Jakub Toth [ 02/Jan/17 ]

https://git.opendaylight.org/gerrit/#/c/49784/

Comment by Martin Ciglan [ 01/Feb/17 ]

boron:

https://git.opendaylight.org/gerrit/#/c/51290/

Comment by Robert Varga [ 02/Feb/17 ]

Reopening, as it breaks format and the patches have been reverted.

Comment by Jakub Toth [ 03/Feb/17 ]

https://git.opendaylight.org/gerrit/#/c/51382/

Comment by Martin Ciglan [ 09/Feb/17 ]

boron backport:
https://git.opendaylight.org/gerrit/#/c/51612

Comment by Jakub Toth [ 13/Feb/17 ]

hotfix:

Generated at Wed Feb 07 20:08:36 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.