Skip to content

Some cleanup#40

Merged
codic12 merged 3 commits intocodic12:mainfrom
hochata:main
Feb 9, 2022
Merged

Some cleanup#40
codic12 merged 3 commits intocodic12:mainfrom
hochata:main

Conversation

@hochata
Copy link

@hochata hochata commented Feb 8, 2022

Hi, just found about this project and I really like it 💯. I was skimming through the code and noticed several simple things that could be improved. No new functionality, just some cleaner code.

Feel free to nitpick stylistic choices. Thanks for the awesome project!

eqf0 added 3 commits February 7, 2022 22:55
Enumerations can hold both a number and a string representation. This
simplifies a little bit the procedures to get the atoms
Reordered the code a little bit to prevent circular dependencies after
deleting the forward declarations.

This resulted in some procedures now living in `events.nim`.
Just looked for repeated patterns across the code and moved some of it
into separate procedures.
@codic12
Copy link
Owner

codic12 commented Feb 9, 2022

Thanks a lot! I've been wanting to refactor the code for a while but haven't gotten around to doing it. Everything here looks good, thanks!

@codic12 codic12 closed this Feb 9, 2022
@codic12 codic12 reopened this Feb 9, 2022
@codic12 codic12 merged commit d891bd6 into codic12:main Feb 9, 2022
@codic12
Copy link
Owner

codic12 commented Feb 11, 2022

I got a chance to test this more extensively, the WM itself still works just fine, but the wormc.nim file's changes broke the format it was sending to worm. I'll try to look into it later, but for now I just reverted the change to wormc.nim (but kept the rest of the refactor.)

@hochata
Copy link
Author

hochata commented Feb 11, 2022

Shame. How did it break? I will look into it as soon as possible.


for i in 1 ..< 5:
if i < params.len:
result[i] = params[i].parseInt().clong
Copy link
Author

Choose a reason for hiding this comment

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

Ok, I think I found an error. Theses indices are wrong. The ith-param should go into the i+1 position of the result because the position 0 is for the atom. Sorry about this.

A correct version would be something like

for i in 0 ..< params.len:
  if i + 1 < result.len:
    result[i + 1] = params[i].parseInt().clong

Copy link
Author

Choose a reason for hiding this comment

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

Or something like this to have the same looping order.

for i in 1 ..< result.len:
  if i - 1 < params.len:
    result[i] = params[i-1].parseInt().clong

@codic12
Copy link
Owner

codic12 commented Feb 11, 2022

Oh yeah, that was definitely the problem, the data being sent to the server didn't really make any sense. Thanks for looking into it, can you make a new pr and replace wormc.nim with the fixed refactored version?

@hochata
Copy link
Author

hochata commented Feb 12, 2022

Sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants