Hacker Newsnew | past | comments | ask | show | jobs | submit | orenht's commentslogin

should be

  typedef struct {uint8_t *data, *dataend} 
if I'm not mistaken :)


What are the advantages of saving the end as a pointer? Genuinely curious. Seems like a length allows the end pointer to be quickly calculated (data + len), while being more useful for comparisons, etc.


You can remove the first k elements of a view with data += k.

With the length you would need to do data += k; length -= k

Especially if you want to use it as safe iterator, you can do data++ in a loop


> ...You can remove the first k elements of a view with data += k.

How would you safely free(data) afterwards? You'd need to keep an alloc'ed pointer somehow.


Got it. That is really neat, going to add to my bag of tricks...


Right. I always think the pointer declaration is part of the type. (that is why I do not use C. Is there really a good reason for this C syntax?)


Do you have any example of that different usage? I can't come up with one


I think it's not a one-time-investment at the beginning which is being measured, but a DCA (Dollar Cost Averaging) over a long period.


You accidentally duplicated the cs50 link. Where were you taking the operating systems class? I'm very interested :)


Sorry. here's the link. You'd love it.

[3]: https://www.ops-class.org


Have you been using it yourself to trade? How good would you say it is?


I don't like the notion of "hacking my brain".

First, it can create long term unwanted needs, such as requiring you to treat yourself for every little achievement. This could lead to a lot of things - weight gain, guilt, or all kinds of addictions (coffee, games..)

Second, I think that improvement is achieved by slow and consistent practice. "Hacks" are... well, hacks. They aren't supposed to be used over and over again.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: