-
-
Notifications
You must be signed in to change notification settings - Fork 608
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
convert aa.c to aarray.d #8831
convert aa.c to aarray.d #8831
Conversation
Thanks for your pull request, @WalterBright! Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub fetch digger
dub run digger -- build "master + dmd#8831" |
078f410
to
de5acdc
Compare
e329eea
to
83748af
Compare
e33ebb0
to
7dc4b3c
Compare
Seems like GitHub doesn't understand the rename. If you can make the rename a separate commit it will be much easier to review. |
It's not a rename, it's a rewrite. aarray.d is a new file, aa.c is deleted. |
src/dmd/backend/aarray.d
Outdated
|
||
alias hash_t = size_t; | ||
|
||
struct aaA |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this can be private.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Does not follow standard D naming conventions
- Please come up with a better name and avoid abbreviations
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's largely copy/pasted from the previous implementation in aa.c. I try to avoid renaming things in the first translated version, for reasons expounded upon several times.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I interpreted your previous comment as this is not a direct translation and therefore added quite a lot of comments that I would not normally do for a direct translation PR.
import core.stdc.stdlib; | ||
import core.stdc.string; | ||
|
||
alias hash_t = size_t; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Private?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it'll be used by anyone using this module.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many of the public functions are missing documentation or missing standard sections like Returns
and Params
.
/* value */ | ||
} | ||
|
||
struct AArray(TKey, Value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No documentation.
|
||
struct AArray(TKey, Value) | ||
{ | ||
alias Key = TKey.Key; // key type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No documentation.
destroy(); | ||
} | ||
|
||
void destroy() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No documentation.
} | ||
} | ||
|
||
size_t length() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No documentation.
/************************************************* | ||
* Get pointer to value in associative array indexed by key. | ||
* Add entry for key if it is not already there. | ||
* Returns: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing Params
section.
if (!nodes) | ||
return null; | ||
|
||
const aligned_keysize = aligntsize(Key.sizeof); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does not follow standard D naming conventions.
if (!nodes) | ||
return; | ||
|
||
size_t newbuckets_length = prime_list[$ - 1]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does not follow standard D naming conventions.
break; | ||
} | ||
} | ||
auto newbuckets = cast(aaA**)calloc(newbuckets_length, (aaA*).sizeof); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does not follow standard D naming conventions.
return (tsize + size_t.sizeof - 1) & ~(size_t.sizeof - 1); | ||
} | ||
|
||
immutable uint[14] prime_list = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does not follow standard D naming conventions.
/***************************************************************/ | ||
|
||
// Simple values | ||
public struct Tinfo(K) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will be by anyone making a simple hash table with a simple key. Currently it is only used by the test code further down.
7dc4b3c
to
6c3a60c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll approve because previous code was just as undocumented so in a way adding docs is "optional". @WalterBright please consider adding docs though prior to merging.
6c3a60c
to
35708f1
Compare
resolved the raised issues
Sigh. I though buildkite was fixed. It's failing again with no log. |
@WalterBright the output is:
Not sure if it's related or expected. |
The semaphoreci one looks spurious as well. |
FYI: dlang/dlang-bot#202 |
Since virtual functions are problematic in -betterC, I replaced the hash table inheritance with parametric polymorphism, i.e. templates. Had to add a little bit extra to interface it with C++. Once it's all in D, the inlining should make it significantly faster.