-
Notifications
You must be signed in to change notification settings - Fork 167
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
bdecoder #31
base: master
Are you sure you want to change the base?
bdecoder #31
Conversation
That looks very good. Rather than walking the dictionary multiple times, once for each key, I suggest we walk it just once, filling in the structures on the fly, doing the loop in On a related note, I suggest creating a struct that contains all the data we're interested in, allocate it in the main loop (on the stack) and having Please make sure that all of your functions are declared (Feel free to |
Line 2848, please use a while loop. |
The parser is designed to be progressive, always returning a pointer to the next character. Since If the code can be very careful to check for keys in lexographic order, it could simply update |
I'm pretty sure your code will be both simpler and cleaner if you do a single pass over the dictionary. Something like
After you've reached the end of the dictionary, you've filled in all the fields of |
Greg, can you please check my branch bdecode and tell me if it's okay to commit that under your name? |
695ebbd
to
b856c94
Compare
I rebased on master and updated the PR. (and then came here and saw your edited comment :/) Yes, feel free to use my name. Also make sure you get the |
Also make sure you get the want = -1
Right.
and while changes
?
|
> and while changes
?
The change in `bdecode_int` to a while loop, as you requested here #31 (comment)
|
Anything left to merge this in? |
Anything left to merge this in?
I want to tweak it some more, but I'm really busy right now. Sorry.
|
It would be great if this could be revisited, is there a reason why it remains in limbo? |
There's absolutely no doubt that @ghazel 's code is both cleaner and more correct than the current hackish code. However, the current code is stable and works well in practice. In order to change it, I'd need (1) a good reason, and (2) a set of unit tests. Concerning (1), except for the intellectual satisfaction of having clean code, what are the advantages to switching to the bdecoder? Concerning (2), who's going to write a set of unit tests so we can switch to Greg's code without fear? |
A few notes:
[[[[...
doesn't add much to the stack