• (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)
    Comment held for moderation.
  • Brian (unregistered)
    Comment held for moderation.
  • (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)
    Comment held for moderation.

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

Log In or post as a guest

Replying to comment #:

« Return to Article