Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
cruft
Oct 25, 2007

fletcher posted:

more eyeballs on it in general.

I just want to highlight that this has turned out to be one of the greatest fallacies about free software. Nothing against you in particular, OP: it's a commonly-held belief.

In fact, if any college goons want a good master's project, try bringing some code up on GitHub, have some cohorts download it, then insert some super-blatant remote shell capabilities into it and see if any automated systems flag that. Maybe they do! I sort of suspect they won't, though.

cruft fucked around with this message at 23:30 on Aug 31, 2023

Adbot
ADBOT LOVES YOU

Breaking Glass
Dec 15, 2021

The vulnerability database is really useful, too: https://pkg.go.dev/vuln/

Jamus
Feb 10, 2007
I write a bit of cgo every now and I sometimes get annoyed by how they’ve made it very difficult to add stuff to the CFLAG headers. However, the reasoning as to why they did it is solid - less chances for arbitrary code execution where you wouldn’t expect it. Anybody who has experienced a NPM package going rogue for political reasons would hopefully sympathise with Go keeping a very tight lid on “neat” dependency manager features.

cruft
Oct 25, 2007

Can some kind soul help me out here

code:
type Attendee struct {
	Email string
	Username string
}

type AttendeeList struct {
	Attendees []Attendee
	ByEmail map[string]Attendee
	ByUsername map[string]Attendee
}
Should I make the Attendee members of AttendeeList pointers?

I'm pretty sure the actual answer is "LOL it's not 1987 you have enough RAM to not care", but it's the principle of the thing, you see.

30.5 Days
Nov 19, 2006

cruft posted:

Can some kind soul help me out here

code:
type Attendee struct {
	Email string
	Username string
}

type AttendeeList struct {
	Attendees []Attendee
	ByEmail map[string]Attendee
	ByUsername map[string]Attendee
}
Should I make the Attendee members of AttendeeList pointers?

I'm pretty sure the actual answer is "LOL it's not 1987 you have enough RAM to not care", but it's the principle of the thing, you see.

If you will be rearranging the list a lot then making it pointers will make it run faster, if you will be iterating over the list a lot then making it not pointers will make it run faster.

consensual poster
Sep 1, 2009

cruft posted:

Can some kind soul help me out here

code:
type Attendee struct {
	Email string
	Username string
}

type AttendeeList struct {
	Attendees []Attendee
	ByEmail map[string]Attendee
	ByUsername map[string]Attendee
}
Should I make the Attendee members of AttendeeList pointers?

I'm pretty sure the actual answer is "LOL it's not 1987 you have enough RAM to not care", but it's the principle of the thing, you see.

Memory usage is not the only consideration. Using pointers, you can modify an attendee and you'll see the update no matter how you access that Attendee.

Pham Nuwen
Oct 30, 2010



consensual poster posted:

Memory usage is not the only consideration. Using pointers, you can modify an attendee and you'll see the update no matter how you access that Attendee.

Particularly since each attendee is duplicated 3x in that struct, it makes sense to work with pointers.

Speaking of that, I'd ask if you really expect to have so many attendees and do so many lookups by both email and by username that it makes sense to duplicate them 3 different ways. My first instinct would be to just hold the slice of Attendees, then iterate for lookups. Iteration is cheaper than you think (especially in this case which won't even have nested loops), and a lot easier than mucking around with 3 different stored representations of the same data.

Adbot
ADBOT LOVES YOU

cruft
Oct 25, 2007

Pham Nuwen posted:

Speaking of that, I'd ask if you really expect to have so many attendees and do so many lookups by both email and by username that it makes sense to duplicate them 3 different ways. My first instinct would be to just hold the slice of Attendees, then iterate for lookups. Iteration is cheaper than you think (especially in this case which won't even have nested loops), and a lot easier than mucking around with 3 different stored representations of the same data.

Haha, great minds think alike, and so do ours! My Scheme training kicked in and I wound up doing exactly this: there's now a type AttendeeList []Attendee that provides some indexing functions by iterating over the slice.

Thanks, everyone. Your replies did steer me toward a nice solution.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply