LGTM On Fri, Jan 22, 2016 at 11:51 AM Dan Cross <[email protected]> wrote:
> On Fri, Jan 22, 2016 at 2:41 PM, ron minnich <[email protected]> wrote: > >> My one suggestion would be that you use the name capacity instead of >> size. These things always confuse me because I can never remember if the >> size is size or len ... I'd spell the full name out (not cap) just to make >> sure people really mean it when they type it -- my fingers tend to type >> size automagically and it's caused me grief. >> > > Done. Though technically no one should ever touch 'capacity'; it should be > more or less opaque. > > Don't we want to throw an error or panic or return an error if a slice_put >> fails? How serious is that? >> > > I made it return 0 if given an out of bounds index. Similarly with > slice_del. I'm not sure if it's serious or not...it's going to depend on > context. > > realloc: nemo did a study (I can get the paper) on whether it's best to >> call realloc with exact sizes or the size*2 type style. Most allocators pad >> underneath, as they have their own rules of thumb, and he concluded based >> on measurement that it's best to call with exact numbers for that reason. >> Things performed better when code did not try to outthink the allocator. >> Note that that rule has failed for me, badly, on Go, but it seems to work >> for most C usages. >> > > If we were going to do that, we could get rid of 'capacity' entirely, but > I'm tempted to let this stand unless it starts to be a problem. > > But, further, most allocators will let you know how much space they >> pre-allocated for your request. So, in Plan 9, people would do stuff like >> this: >> x->ptr = alloc(whatever); >> x->len = whatever; >> x->cap = alloc_cap(x); >> >> where alloc_cap is the way for the allocator to tell you the cap instead >> of you trying to tell it the cap via the size*2 rubric. >> > > The nice thing here is that all of this is hidden behind an interface, so > it's easy to change if need-be. > > size*2 is dicey anyway if things get big, as people find when their arrays >> get to 4k. >> > > If we're getting beyond 4ish k, this is probably the wrong interface... > But let's see when/if we get a second user. > > That said, I think this is basically find as is. Just a few thoughts. I am >> a bit worried about the silent errors. >> > > PTAL. Silent errors are no longer silent. > > - Dan C. > > > On Fri, Jan 22, 2016 at 11:30 AM Dan Cross <[email protected]> wrote: >> >>> The following changes since commit >>> 6ae8195b99f28d2f2735dcde2a723a4bde3142ef: >>> >>> Add taps for pipes. (2016-01-14 16:04:46 -0500) >>> >>> are available in the git repository at: >>> >>> [email protected]:dancrossnyc/akaros.git slice >>> >>> for you to fetch changes up to 85de5d2b5f19f17a615eef83d61905b9d5a4878b: >>> >>> Slices: A growable list of pointers. (2016-01-22 14:29:47 -0500) >>> >>> ---------------------------------------------------------------- >>> Dan Cross (1): >>> Slices: A growable list of pointers. >>> >>> kern/include/slice.h | 24 ++++++++++++++++++++++++ >>> kern/lib/Kbuild | 3 ++- >>> kern/lib/slice.c | 87 >>> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ >>> 3 files changed, 113 insertions(+), 1 deletion(-) >>> create mode 100644 kern/include/slice.h >>> create mode 100644 kern/lib/slice.c >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Akaros" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected]. >>> To post to this group, send email to [email protected]. >>> For more options, visit https://groups.google.com/d/optout. >>> >> -- >> You received this message because you are subscribed to the Google Groups >> "Akaros" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> To post to this group, send email to [email protected]. >> For more options, visit https://groups.google.com/d/optout. >> > -- > You received this message because you are subscribed to the Google Groups > "Akaros" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Akaros" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. For more options, visit https://groups.google.com/d/optout.
