Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring/IsValid #1197

Merged
merged 14 commits into from
Nov 23, 2021
Merged

Refactoring/IsValid #1197

merged 14 commits into from
Nov 23, 2021

Conversation

DaEgi01
Copy link
Contributor

@DaEgi01 DaEgi01 commented Nov 22, 2021

see individual commit, but don't get dizzy ;D
IsValid is static now, hope you like it :P

@DaEgi01 DaEgi01 added the code cleanup Refactor code, remove old code, improve maintainability label Nov 22, 2021
@@ -150,7 +145,8 @@ public void
Log._Debug("Extended building data:");

for (var i = 0; i < ExtBuildings.Length; ++i) {
if (!IsValid((ushort)i)) {
ref Building building = ref ExtBuildings[i].buildingId.ToBuilding();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ups ... gonna change that

@kvakvs
Copy link
Collaborator

kvakvs commented Nov 22, 2021

Did you compare generated .NET bytecode?
Is it at least not worse? Or not significantly slower than the old variant?

@DaEgi01
Copy link
Contributor Author

DaEgi01 commented Nov 22, 2021

nope, did not compare bytecode. but I can do.
I know for sure that some checks are removed due to redundancy, but I have yet to compare the whole thing.
I did not went for speed with this one but just for cleanup.

@kianzarrin
Copy link
Collaborator

I wish we could set the heavy in-lining attribute ( I don't think our version of mono allows that)

/// </summary>
/// <param name="netLane">netLane</param>
/// <returns>True if the netLane and its netSegment is valid, otherwise false.</returns>
public static bool IsValidWithSegment(this ref NetLane netLane) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some mods like MOM add a buggy lane without segment. This might confuse TMPE. but I am not sure if that extra lane can even have traffic so probably not relevant to TMPE. in any case you haven't changed the logic of the code so I don't expect regression.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope I didnt change any logic. but better double check during review in case I mistyped or something. :)

@DaEgi01
Copy link
Contributor Author

DaEgi01 commented Nov 23, 2021

I wish we could set the heavy in-lining attribute ( I don't think our version of mono allows that)

I'll check aggresive inlining. wanted to do that anyway.

Copy link
Member

@krzychu124 krzychu124 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, I didn't find any typos 👍

@DaEgi01
Copy link
Contributor Author

DaEgi01 commented Nov 23, 2021

@kvakvs
image

@DaEgi01 DaEgi01 merged commit 0f6e400 into master Nov 23, 2021
@DaEgi01 DaEgi01 deleted the refactoring/IsValid branch November 23, 2021 19:53
@DaEgi01 DaEgi01 restored the refactoring/IsValid branch November 23, 2021 19:54
@originalfoo originalfoo added this to the 11.6.0 milestone Dec 23, 2021
@originalfoo originalfoo modified the milestones: 11.6.0, 11.6.2 Jan 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code cleanup Refactor code, remove old code, improve maintainability
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants