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
more falafel please
Feb 26, 2005

forums poster

Tei posted:

gently caress speed, gently caress optimizing memory

just write good code that is also easy to read and understand

If the cost is some expensive invisible operation is invoqued when doing ==. So be it.

Edit:
this thread need good old WTFeries. I am doing my part.

Yeah that's a luxury not all of us have. If I could spend a month to save 0.1 ms, I'd get promoted

Adbot
ADBOT LOVES YOU

redleader
Aug 18, 2005

Engage according to operational parameters

more falafel please posted:

Yeah that's a luxury not all of us have. If I could spend a month to save 0.1 ms, I'd get promoted

must be interesting

if i spent a month to save 1s, i'd get fired

Xarn
Jun 26, 2015
These two posts are why whenever someone goes "nobody does X", or "nobody needs X", or "you will never use math in programming", or "you will always need math for programming", I just start rolling my eyes real hard.

Beef
Jul 26, 2004
"You don't need assembly because compilers are so good you never have to touch that. "

*spends half their time trawling though objdumps and instruction traces*

Tei
Feb 19, 2011

more falafel please posted:

Yeah that's a luxury not all of us have. If I could spend a month to save 0.1 ms, I'd get promoted

I am going to be honest. My first reaction was "oh, I want this dude job",

... but I guess if you have to deal with ugly code and absurd complexity + runtime weird problems, then maybe is not fun.

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

Tei posted:

I am going to be honest. My first reaction was "oh, I want this dude job",

... but I guess if you have to deal with ugly code and absurd complexity + runtime weird problems, then maybe is not fun.

The code they're talking about optimizing is likely already very lean, vectorized, and cache optimized. Also only very specific parts of code.

If I had someone who managed to cut .1ms out of the render loop from my team (not deep in the engine or renderer) it'd be an easy case to make for a staff promotion. Potentially a nice spot bonus on top.

Sistergodiva
Jan 3, 2006

I'm like you,
I have no shame.

code:
PreparedStatement statement3 = connection.prepareStatement(String.format(query, asId, asId));
Where was this found?

code:
while (rs4.next())


Somewhere outside of this.


Someone didn't know how to join, so there are 4 while-loops looping over results sets and doing more queries, etc.

NihilCredo
Jun 6, 2011

iram omni possibili modo preme:
plus una illa te diffamabit, quam multæ virtutes commendabunt

Well, it has finally happened, I had a vendor provide us with a mutation API via HTTP GET.

And the documentation didn't mention this, in fact it describes the method in English as "With this method the {thing} will be posted"

And it returns 200 every time it's invoked even when the item has been already irrevocably processed.

And it apparently fires off some asynchronous backend task every time it's invoked.

And of course it's from a multinational enterprise consultancy corporation with literally > 1000x the number of our employees.

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe
you know that thing that some text entry fields do, where you click in them and they automatically select all the text, and if you want to just insert text instead of replace what's there you have to click a second time? does that have a name?

I cannot stand it. It never fails to anger me. I clicked somewhere specific and started typing, intending to insert text into the middle of the text that was already there. But you tricked me into wiping out the text that was there. Thanks rear end in a top hat. If I'd wanted to delete all of the text, guess what? I can use ctrl+A; I'm not stupid.

I use edge on this machine and it defaults to Bing for searching. I didn't give a poo poo about that until today, but Microsoft have now made a change so that the search bar on the search result page exhibits this behaviour. Not only that, but after you accidentally wipe out the text, ctrl+Z to undo doesn't work. Time to set the default search engine to Google I think.

Macichne Leainig
Jul 26, 2012

by VG
Yeah I never understood that. Let the browser handle the behavior, and if the behavior changes then people can get mad at Google or Microsoft whatever. Don't pretend like you're fancy and start loving with people's UX. :argh:

Same with scrolljacking and some of those other things. Developers of those web libraries are the enemy.

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe
my blood pressure was already high enough on account of I'm trying my best to figure out how to make my additions to this horrible legacy WinForms app not look and feel like poo poo.

Presto
Nov 22, 2002

Keep calm and Harry on.

OddObserver posted:

I think someone here needs to be sentenced to spending time with STL map containers. A few ->second.first's and the desire to use these sorts of types for public interfaces flows right out of the window.
code:
for (const auto& [key, value] : myMap) {
    /* some poo poo using key and value */ 
}

Problem solved!

Xarn
Jun 26, 2015
Plot twist, myMap returns its data as (value, key) pair for some godforsaken internal data layout optimization reason.

Presto
Nov 22, 2002

Keep calm and Harry on.

Xarn posted:

Plot twist, myMap returns its data as (value, key) pair for some godforsaken internal data layout optimization reason.
Then it's not an STL map, QED. :smug:

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
Yeah, the STL’s use of std::pair in the map interfaces ends up forbidding all sorts of interesting optimizations like separating the key and value storage. It also used to force certain insertion patterns to be inefficient, but I think that’s fixed now (if you use new API for the insertion).

celestial teapot
Sep 9, 2003

He asked my religion and I replied "agnostic." He asked how to spell it, and remarked with a sigh: "Well, there are many religions, but I suppose they all worship the same God."
If you can figure out what this is trying to do, you get an award

If you can figure out why the gently caress they thought SQL was where it should be done, you get another award

code:
FUNCTION F_NUM_TO_WORD_PREV(p_qty NUMBER)
     RETURN VARCHAR2
   IS
  --
  --
  lv_exist_decimals    varchar2 (2000) := null;
  lv_return            varchar2(32000):= null;
  lv_to_num_array      gv_arrayVarchar;
  --
  BEGIN
  --
  --before all, this going to check id exist decimals for add a 'cents' word
  lv_exist_decimals := TRIM(to_char(p_qty,'999999999999.99MI'));
  --
  lv_to_num_array := f_split(lv_exist_decimals,'.');
  --
  -- start to convert the numbers to words
     FOR i IN 1 .. lv_to_num_array.COUNT LOOP
       --
       --check if has a decimals numbers add more words cents
        if (i = 1) then
           lv_return := TRIM(F_NUM_TO_WORD_SP(to_number(lv_to_num_array(i).R_VALUE)));
        elsif (i = 2) then
            lv_return := lv_return || ' COM '|| TRIM(F_NUM_TO_WORD_SP(to_number(lv_to_num_array(i).R_VALUE)))|| ' CENTAVOS';
        end if;
       
       --
     END LOOP;
  --
  --
    RETURN lv_return;
  --
  END F_NUM_TO_WORD_PREV;
 
  FUNCTION F_NUM_TO_WORD_SP(
       p_qty NUMBER,
       p_currency varchar2 default null,
       p_shortName varchar2 default null)
     RETURN VARCHAR2
   IS

   --
     num_string   VARCHAR2(250);
     zero         VARCHAR2(2);
     errm         VARCHAR2(150);
     varx         VARCHAR2(250);
     multx        VARCHAR2(250);
     numx         VARCHAR2(150);
     numeros      NUMBER;
     l_title      GTVCURR.GTVCURR_TITLE%TYPE;
     l_curr_1     GTVCURR.GTVCURR_TITLE%TYPE;
     l_curr_2     GTVCURR.GTVCURR_TITLE%TYPE;
     l_curr_index INTEGER;

   BEGIN
    num_string                                := ' ';
  --   IF (100 * (ABS(p_qty) - TRUNC(ABS(p_qty))) < 10) AND (100 * (ABS(p_qty) - TRUNC(ABS(p_qty))) > 0) THEN
  --     zero                                    := '0';
  --   ELSE
       zero := NULL;
  --   END IF;
   --    
     l_curr_1 := '';
     l_curr_2 := '';
     numx     := 'x.';
     numeros := 0;
     --
     --
     /*SELECT DECODE(.00000000001                                  * (MOD(ABS(p_qty), 1000000000000) - MOD(ABS(p_qty), 100000000000)), 1, DECODE(SUBSTR(TO_CHAR(TRUNC(p_qty, 0)), -12, 3), '100', 'Cien ', 'Ciento '), 2, 'Doscientos ', 3, 'Trescientos ', 4, 'Cuatrocientos ', 5, 'Quinientos ', 6, 'Seiscientos ', 7, 'Setecientos ', 8, 'Ochocientos ', 9, 'Novecientos ', 0, NULL, 'error')
       || DECODE(.0000000001                                     * (MOD(ABS(p_qty), 100000000000) - MOD(ABS(p_qty), 10000000000)), 1, (DECODE(.000000001 * (MOD(ABS(p_qty), 10000000000) - MOD(ABS(p_qty), 1000000000)), 0, 'Diez ', 1, 'Once ', 2, 'Doce ', 3, 'Trece ', 4, 'Catorce ', 5, 'Quince ', 6, 'Dieciseis ', 7, 'Diecisiete ', 8, 'Dieciocho ', 9, 'Diecinueve ', 'error')), 2, (DECODE(.000000001 * (MOD(ABS(p_qty), 10000000000) - MOD(ABS(p_qty), 1000000000)), 0, 'Veinte ', 1, 'Ventiuno ', 2, 'Veintidos ', 3, 'Veintitres ', 4, 'Veinticuatro ', 5, 'Veinticinco ', 6, 'Veintiseis ', 7, 'Veintisiete ', 8, 'Veintiocho ', 9, 'Veintinueve ', 'error')), 3, 'Treinta ', 4, 'Cuarenta ', 5, 'Cincuenta ', 6, 'Sesenta ', 7, 'Setenta ', 8, 'Ochenta ', 9, 'Noventa ', NULL)
       || DECODE(.000000001                                      * (MOD(ABS(p_qty), 10000000000) - MOD(ABS(p_qty), 1000000000)), 0, NULL, (DECODE(.0000000001 * (MOD(ABS(p_qty), 100000000000) - MOD(ABS(p_qty), 10000000000)), 0, NULL, 1, NULL, 2, NULL, 'y ')))
       || DECODE(.0000000001                                     * (MOD(ABS(p_qty), 100000000000) - MOD(ABS(p_qty), 10000000000)), 1, NULL, 2, NULL, (DECODE(.000000001 * (MOD(ABS(p_qty), 10000000000) - MOD(ABS(p_qty), 1000000000)), 1, 'Un ', 2, 'Dos ', 3, 'Tres ', 4, 'Cuatro ', 5, 'Cinco ', 6, 'Seis ', 7, 'Siete ', 8, 'Ocho ', 9, 'Nueve ', 0, NULL, 'error')))
       || DECODE(SIGN(ABS(p_qty)                                 - 999.99), 1, DECODE(.00000000001 * (MOD(ABS(p_qty), 1000000000000) - MOD(ABS(p_qty), 100000000000)), 0, DECODE(.0000000001 * (MOD(ABS(p_qty), 100000000000) - MOD(ABS(p_qty), 10000000000)), 0, DECODE(.000000001 * (MOD(ABS(p_qty), 10000000000) - MOD(ABS(p_qty), 1000000000)), 0, NULL, DECODE(SUBSTR(TO_CHAR(TRUNC(p_qty, 0)), -10, 1), '1', 'Billon ', 'Billones ')), 'Billones '), 'Billones '), NULL)
       || DECODE(.00000001                                       * (MOD(ABS(p_qty), 1000000000) - MOD(ABS(p_qty), 100000000)), 1, DECODE(SUBSTR(TO_CHAR(TRUNC(p_qty, 0)), -9, 3), '100', 'Cien ', 'Ciento '), 2, 'Doscientos ', 3, 'Trescientos ', 4, 'Cuatrocientos ', 5, 'Quinientos ', 6, 'Seiscientos ', 7, 'Setecientos ', 8, 'Ochocientos ', 9, 'Novecientos ', 0, NULL, 'error')
       || DECODE(.0000001                                        * (MOD(ABS(p_qty), 100000000) - MOD(ABS(p_qty), 10000000)), 1, (DECODE(.000001 * (MOD(ABS(p_qty), 10000000) - MOD(ABS(p_qty), 1000000)), 0, 'Diez ', 1, 'Once ', 2, 'Doce ', 3, 'Trece ', 4, 'Catorce ', 5, 'Quince ', 6, 'Dieciseis ', 7, 'Diecisiete ', 8, 'Dieciocho ', 9, 'Diecinueve ', 'ERROR')), 2, (DECODE(.000001 * (MOD(ABS(p_qty), 10000000) - MOD(ABS(p_qty), 1000000)), 0, 'Veinte ', 1, 'Veintiun ', 2, 'Veintidos ', 3, 'Veintitres ', 4, 'Veinticuatro ', 5, 'Veinticinco ', 6, 'Veintiseis ', 7, 'Veintisiete ', 8, 'Veintiocho ', 9, 'Veintinueve ', 'ERROR')), 3, 'Treinta ', 4, 'Cuarenta ', 5, 'Cincuenta ', 6, 'Sesenta ', 7, 'Setenta ', 8, 'Ochenta ', 9, 'Noventa ', NULL)
       || DECODE(.000001                                         * (MOD(ABS(p_qty), 10000000) - MOD(ABS(p_qty), 1000000)), 0, NULL, (DECODE(.0000001 * (MOD(ABS(p_qty), 100000000) - MOD(ABS(p_qty), 10000000)), 0, NULL, 1, NULL, 2, NULL, 'y ')))
       || DECODE(.0000001                                        * (MOD(ABS(p_qty), 100000000) - MOD(ABS(p_qty), 10000000)), 1, NULL, 2, NULL, (DECODE(.000001 * (MOD(ABS(p_qty), 10000000) - MOD(ABS(p_qty), 1000000)), 1, 'Un ', 2, 'Dos ', 3, 'Tres ', 4, 'Cuatro ', 5, 'Cinco ', 6, 'Seis ', 7, 'Siete ', 8, 'Ocho ', 9, 'Nueve ', 0, NULL, 'error')))
       || DECODE(SIGN(ABS(p_qty)                                 - 999.99), 1, DECODE(.00000001 * (MOD(ABS(p_qty), 1000000000) - MOD(ABS(p_qty), 100000000)), 0, DECODE(.0000001 * (MOD(ABS(p_qty), 100000000) - MOD(ABS(p_qty), 10000000)), 0, DECODE(.000001 * (MOD(ABS(p_qty), 10000000) - MOD(ABS(p_qty), 1000000)), 0, NULL, DECODE(SUBSTR(TO_CHAR(TRUNC(p_qty, 0)), -7, 1), '1', 'Millon ', 'Millones ')), 'Millones '), 'Millones '), NULL)
       || DECODE(.00001                                          * (MOD(ABS(p_qty), 1000000) - MOD(ABS(p_qty), 100000)), 1, DECODE(SUBSTR(TO_CHAR(TRUNC(p_qty, 0)), -6, 3), '100', 'Cien ', 'Ciento '), 2, 'Doscientos ', 3, 'Trescientos ', 4, 'Cuatrocientos ', 5, 'Quinientos ', 6, 'Seiscientos ', 7, 'Setecientos ', 8, 'Ochocientos ', 9, 'Novecientos ', 0, NULL, 'error')
       || DECODE(.0001                                           * (MOD(ABS(p_qty), 100000) - MOD(ABS(p_qty), 10000)), 1, (DECODE(.001 * (MOD(ABS(p_qty), 10000) - MOD(ABS(p_qty), 1000)), 0, 'Diez ', 1, 'Once ', 2, 'Doce ', 3, 'Trece ', 4, 'Catorce ', 5, 'Quince ', 6, 'Dieciseis ', 7, 'Diecisiete ', 8, 'Dieciocho ', 9, 'Diecinueve ', 'ERROR')), 2, (DECODE(.001 * (MOD(ABS(p_qty), 10000) - MOD(ABS(p_qty), 1000)), 0, 'Veinte ', 1, 'Ventiun ', 2, 'Ventidos ', 3, 'Ventitres ', 4, 'Venticuatro ', 5, 'Venticinco ', 6, 'Ventiseis ', 7, 'Ventisiete ', 8, 'Ventiocho ', 9, 'Ventinueve ', 'ERROR')), 3, 'Treinta ', 4, 'Cuarenta ', 5, 'Cincuenta ', 6, 'Sesenta ', 7, 'Setenta ', 8, 'Ochenta ', 9, 'Noventa ', NULL)
       || DECODE(.001                                            * (MOD(ABS(p_qty), 10000) - MOD(ABS(p_qty), 1000)), 0, NULL, (DECODE(.0001 * (MOD(ABS(p_qty), 100000) - MOD(ABS(p_qty), 10000)), 0, NULL, 1, NULL, 2, NULL, 'y ')))
       || DECODE(.0001                                           * (MOD(ABS(p_qty), 100000) - MOD(ABS(p_qty), 10000)), 1, NULL, 2, NULL, (DECODE(.001 * (MOD(ABS(p_qty), 10000) - MOD(ABS(p_qty), 1000)), 1, 'Un ', 2, 'Dos ', 3, 'Tres ', 4, 'Cuatro ', 5, 'Cinco ', 6, 'Seis ', 7, 'Siete ', 8, 'Ocho ', 9, 'Nueve ', 0, NULL, 'error')))
       || DECODE(SIGN(ABS(p_qty)                                 - 999.99), 1, DECODE(.00001 * (MOD(ABS(p_qty), 1000000) - MOD(ABS(p_qty), 100000)), 0, DECODE(.0001 * (MOD(ABS(p_qty), 100000) - MOD(ABS(p_qty), 10000)), 0, DECODE(.001 * (MOD(ABS(p_qty), 10000) - MOD(ABS(p_qty), 1000)), 0, NULL, 'Mil '), 'Mil '), 'Mil '), NULL)
       || DECODE(.01                                             * (MOD(ABS(p_qty), 1000) - MOD(ABS(p_qty), 100)), 1, DECODE(SUBSTR(TO_CHAR(TRUNC(p_qty, 0)), -3, 3), '100', 'Cien ', 'Ciento '), 2, 'Doscientos ', 3, 'Trescientos ', 4, 'Cuatrocientos ', 5, 'Quinientos ', 6, 'Seiscientos ', 7, 'Setecientos ', 8, 'Ochocientos ', 9, 'Novecientos ', NULL)
       || DECODE(.1                                              * (MOD(ABS(p_qty), 100) - MOD(ABS(p_qty), 10)), 1, (DECODE(TRUNC(MOD(ABS(p_qty), 10)), 0, 'Diez ', 1, 'Once ', 2, 'Doce ', 3, 'Trece ', 4, 'Catorce ', 5, 'Quince ', 6, 'Dieciseis ', 7, 'Diecisiete ', 8, 'Dieciocho ', 9, 'Diecinueve ', 'ERROR')), 2, (DECODE(TRUNC(MOD(ABS(p_qty), 10)), 0, 'Veinte ', 1, 'Ventiun ', 2, 'Ventidos ', 3, 'Ventitres ', 4, 'Venticuatro ', 5, 'Venticinco ', 6, 'Ventiseis ', 7, 'Ventisiete ', 8, 'Ventiocho ', 9, 'Ventinueve ', 'ERROR')), 2, 'Veinte ', 3, 'Treinta ', 4, 'Cuarenta ', 5, 'Cincuenta ', 6, 'Sesenta ', 7, 'Setenta ', 8, 'Ochenta ', 9, 'Noventa ', NULL)
       || DECODE(TRUNC(MOD(ABS(p_qty), 10)), 0, NULL, (DECODE(.1 * (MOD(ABS(p_qty), 100) - MOD(ABS(p_qty), 10)), 0, NULL, 1, NULL, 2, NULL, 'y ')))
       || DECODE(.1                                              * (MOD(ABS(p_qty), 100) - MOD(ABS(p_qty), 10)), 1, NULL, 2, NULL, (DECODE(TRUNC(MOD(ABS(p_qty), 10)), 1, 'Un', 2, 'Dos', 3, 'Tres', 4, 'Cuatro', 5, 'Cinco', 6, 'Seis', 7, 'Siete', 8, 'Ocho', 9, 'Nueve', 0, NULL, 'error')))
       || DECODE(MOD(TRUNC(p_qty, 0), 1000000), 0, DECODE(p_qty, 0, NULL, 'de '), NULL)
       || DECODE(TRUNC(p_qty, 0), 0, 'Cero ', NULL)
       || zero
       || ' '
       || DECODE(TRUNC(p_qty, 0), 1, l_curr_1, l_curr_2)
       || ' '
       || LPAD(DECODE(100 * (ABS(p_qty) - TRUNC(ABS(p_qty))), 0, '00', 100 * (ABS(p_qty) - TRUNC(ABS(p_qty)))), 2, '0')
       || '/100 '*/
    SELECT DECODE(.00000000001                                  * (MOD(ABS(p_qty), 1000000000000) - MOD(ABS(p_qty), 100000000000)), 1, DECODE(SUBSTR(TO_CHAR(TRUNC(p_qty, 0)), -12, 3), '100', 'Cem ', 'cento '), 2, 'Duzentos ', 3, 'Trezentos ', 4, 'Quatrocentos ', 5, 'Quinhentos ', 6, 'Seiscentos ', 7, 'Setecentos ', 8, 'oitocentos ', 9, 'Novecentos ', 0, NULL, 'error')
       || DECODE(.0000000001                                     * (MOD(ABS(p_qty), 100000000000) - MOD(ABS(p_qty), 10000000000)), 1, (DECODE(.000000001 * (MOD(ABS(p_qty), 10000000000) - MOD(ABS(p_qty), 1000000000)), 0, 'Dez ', 1, 'Onze ', 2, 'Doze ', 3, 'Treze ', 4, 'Quatorze ', 5, 'Quinze ', 6, 'Dezesseis ', 7, 'Dezessete ', 8, 'Dezoito ', 9, 'Dezenove ', 'error')), 2, (DECODE(.000000001 * (MOD(ABS(p_qty), 10000000000) - MOD(ABS(p_qty), 1000000000)), 0, 'Vinte ', 1, 'Vinte e um ', 2, 'Vinte e dois ', 3, 'Vinte e tręs ', 4, 'Vinte e quatro ', 5, 'Vinte e cinco ', 6, 'Vinte e seis ', 7, 'Vinte e sete ', 8, 'Vinte e oito ', 9, 'Vinte e nove ', 'error')), 3, 'Trinta ', 4, 'Quarenta ', 5, 'Cinqüenta ', 6, 'Sessenta ', 7, 'Setenta ', 8, 'Oitenta ', 9, 'Noventa ', NULL)
       || DECODE(.000000001                                      * (MOD(ABS(p_qty), 10000000000) - MOD(ABS(p_qty), 1000000000)), 0, NULL, (DECODE(.0000000001 * (MOD(ABS(p_qty), 100000000000) - MOD(ABS(p_qty), 10000000000)), 0, NULL, 1, NULL, 2, NULL, 'e ')))
       || DECODE(.0000000001                                     * (MOD(ABS(p_qty), 100000000000) - MOD(ABS(p_qty), 10000000000)), 1, NULL, 2, NULL, (DECODE(.000000001 * (MOD(ABS(p_qty), 10000000000) - MOD(ABS(p_qty), 1000000000)), 1, 'Un ', 2, 'Dois ', 3, 'Tręs ', 4, 'Quatro ', 5, 'Cinco ', 6, 'Seis ', 7, 'Sete ', 8, 'Oito ', 9, 'Nove ', 0, NULL, 'error')))
       || DECODE(SIGN(ABS(p_qty)                                 - 999.99), 1, DECODE(.00000000001 * (MOD(ABS(p_qty), 1000000000000) - MOD(ABS(p_qty), 100000000000)), 0, DECODE(.0000000001 * (MOD(ABS(p_qty), 100000000000) - MOD(ABS(p_qty), 10000000000)), 0, DECODE(.000000001 * (MOD(ABS(p_qty), 10000000000) - MOD(ABS(p_qty), 1000000000)), 0, NULL, DECODE(SUBSTR(TO_CHAR(TRUNC(p_qty, 0)), -10, 1), '1', 'Billon ', 'Bilhőes ')), 'Bilhőes '), 'Bilhőes '), NULL)
       || DECODE(.00000001                                       * (MOD(ABS(p_qty), 1000000000) - MOD(ABS(p_qty), 100000000)), 1, DECODE(SUBSTR(TO_CHAR(TRUNC(p_qty, 0)), -9, 3), '100', 'Cem ', 'cento '), 2, 'Duzentos ', 3, 'Trezentos ', 4, 'Quatrocentos ', 5, 'Quinhentos ', 6, 'Seiscentos ', 7, 'Setecentos ', 8, 'oitocentos ', 9, 'Novecentos ', 0, NULL, 'error')
       || DECODE(.0000001                                        * (MOD(ABS(p_qty), 100000000) - MOD(ABS(p_qty), 10000000)), 1, (DECODE(.000001 * (MOD(ABS(p_qty), 10000000) - MOD(ABS(p_qty), 1000000)), 0, 'Dez ', 1, 'Onze ', 2, 'Doze ', 3, 'Treze ', 4, 'Quatorze ', 5, 'Quinze ', 6, 'Dezesseis ', 7, 'Dezessete ', 8, 'Dezoito ', 9, 'Dezenove ', 'ERROR')), 2, (DECODE(.000001 * (MOD(ABS(p_qty), 10000000) - MOD(ABS(p_qty), 1000000)), 0, 'Vinte ', 1, 'Vinte e um ', 2, 'Vinte e dois ', 3, 'Vinte e tręs ', 4, 'Vinte e quatro ', 5, 'Vinte e cinco ', 6, 'Vinte e seis ', 7, 'Vinte e sete ', 8, 'Vinte e oito ', 9, 'Vinte e nove ', 'ERROR')), 3, 'Trinta ', 4, 'Quarenta ', 5, 'Cinqüenta ', 6, 'Sessenta ', 7, 'Setenta ', 8, 'Oitenta ', 9, 'Noventa ', NULL)
       || DECODE(.000001                                         * (MOD(ABS(p_qty), 10000000) - MOD(ABS(p_qty), 1000000)), 0, NULL, (DECODE(.0000001 * (MOD(ABS(p_qty), 100000000) - MOD(ABS(p_qty), 10000000)), 0, NULL, 1, NULL, 2, NULL, 'e ')))
       || DECODE(.0000001                                        * (MOD(ABS(p_qty), 100000000) - MOD(ABS(p_qty), 10000000)), 1, NULL, 2, NULL, (DECODE(.000001 * (MOD(ABS(p_qty), 10000000) - MOD(ABS(p_qty), 1000000)), 1, 'Un ', 2, 'Dois ', 3, 'Tręs ', 4, 'Quatro ', 5, 'Cinco ', 6, 'Seis ', 7, 'Sete ', 8, 'Oito ', 9, 'Nove ', 0, NULL, 'error')))
       || DECODE(SIGN(ABS(p_qty)                                 - 999.99), 1, DECODE(.00000001 * (MOD(ABS(p_qty), 1000000000) - MOD(ABS(p_qty), 100000000)), 0, DECODE(.0000001 * (MOD(ABS(p_qty), 100000000) - MOD(ABS(p_qty), 10000000)), 0, DECODE(.000001 * (MOD(ABS(p_qty), 10000000) - MOD(ABS(p_qty), 1000000)), 0, NULL, DECODE(SUBSTR(TO_CHAR(TRUNC(p_qty, 0)), -7, 1), '1', 'Millon ', 'Milhőes ')), 'Milhőes '), 'Milhőes '), NULL)
           || DECODE(.00001                                          * (MOD(ABS(p_qty), 1000000) - MOD(ABS(p_qty), 100000)), 1, DECODE(SUBSTR(TO_CHAR(TRUNC(p_qty, 0)), -6, 3), '100', 'Cem ', 'cento '), 2, 'Duzentos ', 3, 'Trezentos ', 4, 'Quatrocentos ', 5, 'Quinhentos ', 6, 'Seiscentos ', 7, 'Setecentos ', 8, 'oitocentos ', 9, 'Novecentos ', 0, NULL, 'error')
       || DECODE(.0001                                           * (MOD(ABS(p_qty), 100000) - MOD(ABS(p_qty), 10000)), 1, (DECODE(.001 * (MOD(ABS(p_qty), 10000) - MOD(ABS(p_qty), 1000)), 0, 'Dez ', 1, 'Onze ', 2, 'Doze ', 3, 'Treze ', 4, 'Quatorze ', 5, 'Quinze ', 6, 'Dezesseis ', 7, 'Dezessete ', 8, 'Dezoito ', 9, 'Dezenove ', 'ERROR')), 2, (DECODE(.001 * (MOD(ABS(p_qty), 10000) - MOD(ABS(p_qty), 1000)), 0, 'Vinte ', 1, 'Vinte e um ', 2, 'Vinte e dois ', 3, 'Vinte e tręs ', 4, 'Vinte e quatro ', 5, 'Vinte e cinco ', 6, 'Vinte e seis ', 7, 'Vinte e sete ', 8, 'Vinte e oito ', 9, 'Vinte e nove ', 'ERROR')), 3, 'Trinta ', 4, 'Quarenta ', 5, 'Cinqüenta ', 6, 'Sessenta ', 7, 'Setenta ', 8, 'Oitenta ', 9, 'Noventa ', NULL)
       || DECODE(.001                                            * (MOD(ABS(p_qty), 10000) - MOD(ABS(p_qty), 1000)), 0, NULL, (DECODE(.0001 * (MOD(ABS(p_qty), 100000) - MOD(ABS(p_qty), 10000)), 0, NULL, 1, NULL, 2, NULL, 'e ')))
       || DECODE(.0001                                           * (MOD(ABS(p_qty), 100000) - MOD(ABS(p_qty), 10000)), 1, NULL, 2, NULL, (DECODE(.001 * (MOD(ABS(p_qty), 10000) - MOD(ABS(p_qty), 1000)), 1, 'Un ', 2, 'Dois ', 3, 'Tręs ', 4, 'Quatro ', 5, 'Cinco ', 6, 'Seis ', 7, 'Sete ', 8, 'Oito ', 9, 'Nove ', 0, NULL, 'error')))
       || DECODE(SIGN(ABS(p_qty)                                 - 999.99), 1, DECODE(.00001 * (MOD(ABS(p_qty), 1000000) - MOD(ABS(p_qty), 100000)), 0, DECODE(.0001 * (MOD(ABS(p_qty), 100000) - MOD(ABS(p_qty), 10000)), 0, DECODE(.001 * (MOD(ABS(p_qty), 10000) - MOD(ABS(p_qty), 1000)), 0, NULL, 'Mil e '), 'Mil '), 'Mil e '), NULL)
       || DECODE(.01                                             * (MOD(ABS(p_qty), 1000) - MOD(ABS(p_qty), 100)), 1, DECODE(SUBSTR(TO_CHAR(TRUNC(p_qty, 0)), -3, 3), '100', 'Cem ', 'cento '), 2, 'Duzentos ', 3, 'Trezentos ', 4, 'Quatrocentos ', 5, 'Quinhentos ', 6, 'Seiscentos ', 7, 'Setecentos ', 8, 'oitocentos ', 9, 'Novecentos ', NULL)
       || DECODE(.1                                              * (MOD(ABS(p_qty), 100) - MOD(ABS(p_qty), 10)), 1, (DECODE(TRUNC(MOD(ABS(p_qty), 10)), 0, 'Dez ', 1, 'Onze ', 2, 'Doze ', 3, 'Treze ', 4, 'Quatorze ', 5, 'Quinze ', 6, 'Dezesseis ', 7, 'Dezessete ', 8, 'Dezoito ', 9, 'Dezenove ', 'ERROR')), 2, (DECODE(TRUNC(MOD(ABS(p_qty), 10)), 0, 'Vinte ', 1, 'Vinte e um ', 2, 'Vinte e dois ', 3, 'Vinte e tręs ', 4, 'Vinte e quatro ', 5, 'Vinte e cinco ', 6, 'Vinte e seis ', 7, 'Vinte e sete ', 8, 'Vinte e oito ', 9, 'Vinte e nove ', 'ERROR')), 2, 'Vinte ', 3, 'Trinta ', 4, 'Quarenta ', 5, 'Cinqüenta ', 6, 'Sessenta ', 7, 'Setenta ', 8, 'Oitenta ', 9, 'Noventa ', NULL)
       || DECODE(TRUNC(MOD(ABS(p_qty), 10)), 0, NULL, (DECODE(.1 * (MOD(ABS(p_qty), 100) - MOD(ABS(p_qty), 10)), 0, NULL, 1, NULL, 2, NULL, 'e ')))
       || DECODE(.1                                              * (MOD(ABS(p_qty), 100) - MOD(ABS(p_qty), 10)), 1, NULL, 2, NULL, (DECODE(TRUNC(MOD(ABS(p_qty), 10)), 1, 'Un', 2, 'Dois', 3, 'Tręs', 4, 'Cuatro', 5, 'Cinco', 6, 'Seis', 7, 'Sete', 8, 'Oito', 9, 'Nove', 0, NULL, 'error')))
       || DECODE(MOD(TRUNC(p_qty, 0), 1000000), 0, DECODE(p_qty, 0, NULL, 'de '), NULL)
       || DECODE(TRUNC(p_qty, 0), 0, 'Zero ', NULL)
       || zero
       || ' '
       || DECODE(TRUNC(p_qty, 0), 1, l_curr_1, l_curr_2)
       || ' '
       --|| LPAD(DECODE(100 * (ABS(p_qty) - TRUNC(ABS(p_qty))), 0, '00', 100 * (ABS(p_qty) - TRUNC(ABS(p_qty)))), 2, '0')
       --|| '/100 '
     INTO num_string
     FROM DUAL;
      numeros  := LENGTH( num_string ) + 10;
    IF numeros <95 THEN
     multx := ((94 - (FLOOR(numeros))));
      --varx := lpad(' ', multx, 'x.');
      varx := lpad(' ', multx, '');
    --RETURN UPPER(num_string) ||nvl(p_shortName, p_currency) ||'  M/Cte. '||(varx);
    RETURN UPPER(num_string) ||nvl(p_shortName, p_currency) ||''||(varx);
  ELSE
   multx := (185 - (FLOOR(numeros)));
    --varx := lpad(' ', multx, 'x.');
    varx := lpad(' ', multx, '');
    --RETURN UPPER(num_string) || nvl(p_shortName, p_currency) ||'  M/Cte. '||(varx);
    RETURN UPPER(num_string) || nvl(p_shortName, p_currency) ||''||(varx);
  END IF;
     RETURN NULL;
   EXCEPTION
   WHEN NO_DATA_FOUND THEN
     RETURN('NO_DATA_FOUND');
   WHEN OTHERS THEN
     RETURN('ERROR');
   END F_NUM_TO_WORD_SP;

Volguus
Mar 3, 2009
It looks like number to words. The kind that one can probably see on a cheque, such as: 1050 to "One thousand and fifty". Why in SQL? When you have a hammer, everything is a nail.
Edit: thinking about it a bit, it could be part of a report that was generated from the database, and at some point someone wanted to have the numbers in words (banks love that poo poo) and the only reasonable thing to do was to add it as a SQL function to that report, since it had to be finished yesterday. Or maybe it would have been even harder in COBOL.

To accomplish this is ugly in any programming language, how ugly it depends in what language your output should be. It looks like spanish. I don't speak any spanish, but I did have to write something like this 20 years ago (in Java) to output in Romanian. And, you're trying to find patterns (English is a lot easier for that), but at some point you just have to add the if/else or switch statements, for numbers that simply do not fit a pattern. French would be even uglier with how they speak 80-s and 90-s. It's gonna be a beast no matter what.

Volguus fucked around with this message at 04:31 on Nov 11, 2021

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

rjmccall posted:

Yeah, the STL’s use of std::pair in the map interfaces ends up forbidding all sorts of interesting optimizations like separating the key and value storage. It also used to force certain insertion patterns to be inefficient, but I think that’s fixed now (if you use new API for the insertion).

"std::map and std::unordered_map are actually kinda bad" pretty consistently shocks the people newer to using C++ that I've worked with. These days everyone just assumes that the standard library types must be savagely optimized and amazing and I've had to explain a whole bunch of times how some API decisions made decades ago accidentally ensured that they can't be that.

ultrafilter
Aug 23, 2007

It's okay if you have any questions.


What's recommended instead?

OddObserver
Apr 3, 2009

Plorkyeran posted:

"std::map and std::unordered_map are actually kinda bad" pretty consistently shocks the people newer to using C++ that I've worked with. These days everyone just assumes that the standard library types must be savagely optimized and amazing and I've had to explain a whole bunch of times how some API decisions made decades ago accidentally ensured that they can't be that.

A real low-light is std::dequeue (and therefore typical use of std::queue), which depending on implementation can easily end up using a minimum of 512 bytes or event 4KiB for a queue which may, say, typically contain only a couple of pointers or something tiny like that.

Edit: so this discussion led me on a tangent and apparently the bucket API of std::unordered_map is a thing:
https://en.cppreference.com/w/cpp/container/unordered_map/bucket_size

.... which I think belongs in this thread.

OddObserver fucked around with this message at 05:19 on Nov 11, 2021

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
The recommended replacement would be whatever uberlibrary framework your org already uses, probably. Pretty sure they all have alternative contains-things-but-isn't-technically-an-stl-container implementations.

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
The funny thing is that a lot of them inherit the STL’s interface, just making weaker guarantees, so they still use std::pair to store entries and so on.

Xarn
Jun 26, 2015
Something something drop in replacement

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?
My fav is std::vector<bool>, which works differently from all other std::vector, being stored under-the-hood as bits packed into wider values. As a result, you can't take references to individual values (at least not the normal way) and concurrent modifications to different elements on different threads are not guaranteed to be safe. That last part caused a bug that took several weeks to fix on my previous job (I got to be the hero on that one because I overheard a discussion and knew about the weird behaviour due to this very thread).

elite_garbage_man
Apr 3, 2010
I THINK THAT "PRIMA DONNA" IS "PRE-MADONNA". I MAY BE ILLITERATE.
my favorite map pattern is when we iterate over the map looking for a specific value

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
The worst parts of the STL are almost always the "we wrote part of the STL as an example of how to use a specific language feature" bits.

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

elite_garbage_man posted:

my favorite map pattern is when we iterate over the map looking for a specific key

Fixed

DoctorTristan
Mar 11, 2006

I would look up into your lifeless eyes and wave, like this. Can you and your associates arrange that for me, Mr. Morden?

celestial teapot posted:

If you can figure out what this is trying to do, you get an award

If you can figure out why the gently caress they thought SQL was where it should be done, you get another award

My guess is there was a tableau dashboard somewhere that was used to present numbers to the c-suite, then someone went “Hey, I’d like those numbers turned into words; see to it by cob Wednesday”

DoctorTristan
Mar 11, 2006

I would look up into your lifeless eyes and wave, like this. Can you and your associates arrange that for me, Mr. Morden?

Jabor posted:

The worst parts of the STL are almost always the "we wrote part of the STL as an example of how to use a specific language feature" bits.

I haven’t had to touch C++ or the STL in over a decade - did they ever fix vector<bool> ?

chglcu
May 17, 2007

I'm so bored with the USA.
The worst part about STL is that it’s C++, and that’s a garbage language for garbage people. I say that as someone who’s used it almost every day for the last 20 or so years. Really wish the game industry had just stuck with C most of the time.

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

chglcu posted:

The worst part about STL is that it’s C++, and that’s a garbage language for garbage people. I say that as someone who’s used it almost every day for the last 20 or so years. Really wish the game industry had just stuck with C most of the time.

It's before my time, so I don't really understand why games moved to C++. Especially since they do their damnedest to avoid half the things that make it nicer from a user perspective.

The feel I get from C++ people when they talk to games people about what games wants to do/change in the language is "why do you even want C++ if you don't want C++"

chglcu
May 17, 2007

I'm so bored with the USA.

leper khan posted:

It's before my time, so I don't really understand why games moved to C++. Especially since they do their damnedest to avoid half the things that make it nicer from a user perspective.

The feel I get from C++ people when they talk to games people about what games wants to do/change in the language is "why do you even want C++ if you don't want C++"

The shift also happened before my time in the industry proper, but I'm guessing a few of the actually nice features gradually won people over. Of course, we all disagree on what those nice features are. My list is namespaces, function (but not operator) overloading and templates (used judiciously). That's all I really miss when I use C.

ultrafilter
Aug 23, 2007

It's okay if you have any questions.


DoctorTristan posted:

I haven’t had to touch C++ or the STL in over a decade - did they ever fix vector<bool> ?

Whether it's a standard vector or not is implementation-dependent.

champagne posting
Apr 5, 2006

YOU ARE A BRAIN
IN A BUNKER

leper khan posted:

It's before my time, so I don't really understand why games moved to C++. Especially since they do their damnedest to avoid half the things that make it nicer from a user perspective.

The feel I get from C++ people when they talk to games people about what games wants to do/change in the language is "why do you even want C++ if you don't want C++"

I thought this change to C++ happened when the alternative was Java in its infancy or no real third alternative.

DoctorTristan
Mar 11, 2006

I would look up into your lifeless eyes and wave, like this. Can you and your associates arrange that for me, Mr. Morden?

ultrafilter posted:

Whether it's a standard vector or not is implementation-dependent.

In my heart I always knew the answer would be “They instead found a way to make it worse”

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

ultrafilter posted:

Whether it's a standard vector or not is implementation-dependent.

No it isn't. It's not required to be more space efficient than a normal vector, but unspecialized vector<T> is not a legal implementation of vector<bool>.

Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...

Plorkyeran posted:

"std::map and std::unordered_map are actually kinda bad" pretty consistently shocks the people newer to using C++ that I've worked with. These days everyone just assumes that the standard library types must be savagely optimized and amazing and I've had to explain a whole bunch of times how some API decisions made decades ago accidentally ensured that they can't be that.

The STL may be bad, but let me tell you, what came before it was way worse. I used to have to deal with macro based container implementations (hi HP codelibs, too bad your lovely compiler can't do templates) and libraries where everything you wanted to put into a container had to derive from a single base class (hi RogueWave). Reading the STL paper was like Jake Blues seeing the ray of light in the church.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
The STL is pretty amazing overall. It's just 30 years old and has a lot of little mistakes that can never be fixed because it got baked into a language unwilling to make backwards-incompatible changes.

nielsm
Jun 1, 2009



Can we fix it when Modules arrive?


(I'm sure the answer is "no".)

Adbot
ADBOT LOVES YOU

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
No, the std2 idea got shot down pretty hard.

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