• (nodebb)

    Well, frist of all, if you're looking for a string representation of a contiguous netmask(1) based on a prefix length, it probably is faster to just look it up in an array of pre-formatted strings...

    (1) No, the strings in the array are not subnets. ("Subnets" as a general thing arguably became obsolete with the introduction of CIDR way back in the way back.) They are dot.te.dqu.ads that represent the masks you can use to extract the network number from a complete IP address, i.e. netmasks.

  • (nodebb)

    I smell a different WTF here.$var = @("list"); isn't valid Perl- at least not in the last 15 years that I've been using it. The '@' sigil is used to dereference a name as an array. That won't work for anonymous lists/arrays.

  • (nodebb) in reply to Steve_The_Cynic

    it probably is faster

    Yea, but who cares? That's the whole point, implementing this in a way that no one can see if this is some list of network id's that follow a pattern, or if it has been manipulated in some way. Readability and maintainability are far more important than execution speed in almost all network management scenarios.

  • (nodebb)

    Ever hear of

    new line

    characters to

    make your comments

    readable?!?

    Addendum 2025-06-18 09:55: Whoops! I was trying to use hash characters at the beginning of each line... and I made a rather different point than I intended.

  • (nodebb)

    # Ever hear of RTFM for the formatting system used on many messageboards?

    Now let's see if I got this right the frist time. 3 ... 2 ... 1 ... {wince} [Submit]

    Addendum 2025-06-18 10:26: Yaay!! ;)

  • Kenn Humborg (unregistered)

    Fixed that for them:

    Looking up a value in an array was faster to code than any mathematical solution.

  • Brian (unregistered)
    what are they doing where performance matters that much?

    As one currently on the job hunt, I gripe all the time about the prevalence of "DSA" interviews and Leetcode, because they focus on exactly the wrong things. Who cares about the big-O of your function if it's an unreadable mess of cleverness with all kinds of nasty side effects?

    I can just see this guy bragging "Yeah, I reduced this function from O(n) to O(1). Aren't I awesome?"

  • (nodebb) in reply to Jaime

    Yea, but who cares?

    Not you, obviously, and not me either, to be honest. I'd take the hit on the time necessary to calculate an appropriate-valued integer type and then format it.

    In C/C++, I'd calculate the not-yet-formatted uint-ish value as (uint32_t)((~(0xFFFFFFFFULL << prefixlen)) & 0xFFFFFFFF), which admittedly isn't exactly clear, but does the work necessary. And yes, it would be ffffffffull of unreadibility. The primary sin of the code in the article is calling the values for netmasks by the name "subnets".

  • AzureDiamond (unregistered)

    if this was a better language i would just generate the list with consteval/comptime dont need to worry about trading readability for speed

  • (nodebb) in reply to WTFGuy

    Ever heard of Disqus? If your forum system needs a manual (yes this system NEEDS a manual) for people to be able to use it... that's a WTF right there... It's a FORUM system!

    Addendum 2025-06-18 14:23: no, I will never reply to any replies. I don't even know where to find any updates... I don't even know where the G-D manual is.

  • Hanzito (unregistered)

    People are being quite #### in this thread.

  • (nodebb)

    Can people stop listing things on the same line like this? Newlines are free

  • Duke of New York (unregistered) in reply to thaines.astro

    After 15 years coding in Perl it's a wonder you're still able to smell anything.

  • (nodebb)

    I wonder if the comments were directed towards colleagues, or their own internal voice?

  • (nodebb) in reply to WTFGuy

    What M? :-)

  • Loren Pechtel (unregistered)

    We have two possible failure modes here:

    1. Something in the list is wrong.

    2. The code to generate the list is wrong.

    Which is easier to spot?

    I generally favor pre-calculating small, fixed lists. Generate anything too big to easily eyeball.

  • Drak (unregistered) in reply to Kenn Humborg
    Comment held for moderation.

Leave a comment on “Stop Being So ####”

Log In or post as a guest

Replying to comment #681413:

« Return to Article