|
Unfortunately no code, but not lacking on humor.quote:searching concurrent linked list; I don't want to make copies of the list. Too expensive. Mom pays for my hardware. http://stackoverflow.com/questions/4178132/searching-concurrent-linked-list
|
# ? Nov 14, 2010 17:18 |
|
|
# ? May 16, 2024 09:17 |
|
C++ written by a former Fortran programmer:code:
(You don't want to see the GTK interface code...)
|
# ? Nov 14, 2010 19:42 |
|
Scaevolus: Maybe I'm the coding horror here, but that could be a lot worse. Assuming all the settings are already stored in a single object, that seems like a halfway reasonable way to serialize and deserialize them without worring about breaking everything when you add a field. The main problem would appear to be a failure to organize the data with any kind of heirarchy.
|
# ? Nov 14, 2010 19:59 |
|
Internet Janitor posted:Scaevolus: Maybe I'm the coding horror here, but that could be a lot worse. Assuming all the settings are already stored in a single object, that seems like a halfway reasonable way to serialize and deserialize them without worring about breaking everything when you add a field. The main problem would appear to be a failure to organize the data with any kind of heirarchy. Well, first of all, there's this line: code:
|
# ? Nov 14, 2010 21:19 |
|
Internet Janitor posted:Maybe I'm the coding horror here, "What is a dispatch table? Hell, what is a hash table even?"
|
# ? Nov 15, 2010 02:11 |
|
Did the C++ thread not just tell a guy to go ahead with lots of string comparisons instead of bothering with a hashmap or whatever
|
# ? Nov 15, 2010 02:39 |
|
Vanadium posted:Did the C++ thread not just tell a guy to go ahead with lots of string comparisons instead of bothering with a hashmap or whatever Are we talking about the thing where someone recommended some god-forsaken academic wackadoo datastruture that was completely inappropriate in place of a hashtable?
|
# ? Nov 15, 2010 06:11 |
|
Otto Skorzeny posted:"What is a dispatch table? Hell, what is a hash table even?" What do you think this is, Python? Making functions is expensive and verbose in C++. Do you want a zillion little classes overriding operator()? If that code's running noticeably slow the author can just split the conditionals into those with strings less than "l" and those greater, and then do if (0 > strcmp(str1, "l")) { ... } else { ... } for an instant doubling of performance. This could be done a few more times and it's much better than using some crazy advanced parser.
|
# ? Nov 15, 2010 06:28 |
|
shrughes posted:What do you think this is, Python? Making functions is expensive and verbose in C++. While a dispatch table is inconvenient in this case without C++0x lambdas, a hash of values is still more convenient than two hundred and change else ifs and strcmps, without taking the improvement in asymptotic performance into account. shrughes posted:Do you want a zillion little classes overriding operator()? "What is a function pointer?"
|
# ? Nov 15, 2010 06:44 |
|
You needn't even get that fancy; a simple parser class could clean up the duplicated code and symbol vomit:code:
|
# ? Nov 15, 2010 06:58 |
|
Janin posted:You needn't even get that fancy; a simple parser class could clean up the duplicated code and symbol vomit:
|
# ? Nov 15, 2010 09:26 |
|
shrughes posted:What do you think this is, Python? Making functions is expensive and verbose in C++.
|
# ? Nov 15, 2010 15:52 |
|
Mustach posted:What the gently caress kind of expensive are you talking about? whoooooosh
|
# ? Nov 15, 2010 20:49 |
|
Ah yes, that was a hilarious joke, my bad.
|
# ? Nov 15, 2010 20:52 |
|
I don't know if I'm the only one who didn't notice that 200 lines had been removed from that. It's a lot worse that way.
|
# ? Nov 16, 2010 00:32 |
|
GrumpyDoctor posted:I don't know if I'm the only one who didn't notice that 200 lines had been removed from that. It's a lot worse that way. I don't understand how someone can be more than about 10% of the way into that and not stop and look for a better way.
|
# ? Nov 16, 2010 00:34 |
|
Munkeymon: If you're reading and writing a preferences object with 200 fields, it's going to take about 200 lines, even if you use something more succinct like what Janin suggested. We could store all that stuff as a JSON associative array and have even less code per property, but we'd still have to load and unload all the fields from it. If you have a built-in serialization system, awesome, but most of the time those generate output that only works with the right version of the class that made it, so forget adding or changing fields.
|
# ? Nov 16, 2010 03:36 |
|
Mustach posted:What the gently caress kind of expensive are you talking about? In terms of programmer time. It is more annoying to have to jump around from the setting keyword to the code associated with the setting. And it is more typing.
|
# ? Nov 16, 2010 05:20 |
|
Okay. I disagree with you a little bit on that, but not enough to argue (or to change similarly-reasoned code if I were to run into it at work).
|
# ? Nov 16, 2010 13:36 |
|
Internet Janitor posted:Munkeymon: If you're reading and writing a preferences object with 200 fields, it's going to take about 200 lines, even if you use something more succinct like what Janin suggested. We could store all that stuff as a JSON associative array and have even less code per property, but we'd still have to load and unload all the fields from it. If you have a built-in serialization system, awesome, but most of the time those generate output that only works with the right version of the class that made it, so forget adding or changing fields. So, after a quarter century, nobody has come up with any way to load data from a file into class fields in C++ that doesn't involve copying and pasting (potentially) hundreds of lines of code by hand?
|
# ? Nov 16, 2010 16:11 |
|
That depends on the format of the file. If we're dealing with a human-readable, unordered, key-value config file, well how could you associate a string literal with a symbol at runtime?
|
# ? Nov 16, 2010 18:01 |
|
Dicky B posted:That depends on the format of the file. If we're dealing with a human-readable, unordered, key-value config file, well how could you associate a string literal with a symbol at runtime? code:
|
# ? Nov 16, 2010 18:13 |
|
Dicky B posted:That depends on the format of the file. If we're dealing with a human-readable, unordered, key-value config file, well how could you associate a string literal with a symbol at runtime?
|
# ? Nov 16, 2010 18:14 |
|
Internet Janitor posted:Munkeymon: If you're reading and writing a preferences object with 200 fields, it's going to take about 200 lines, even if you use something more succinct like what Janin suggested. We could store all that stuff as a JSON associative array and have even less code per property, but we'd still have to load and unload all the fields from it. If you have a built-in serialization system, awesome, but most of the time those generate output that only works with the right version of the class that made it, so forget adding or changing fields. You don't have to do it with a 200-line long conditional construction though.
|
# ? Nov 16, 2010 18:15 |
|
Janin posted:Use a schema file to auto-generate both the storage class/struct and its serialisation procedure. A partial example of this is google's protocol buffers. Because it creates reflectable run-time structures, it can serialize to pretty much anything. However it does not boil down to a struct, so it is not quiet as simple to work with as a struct would be.
|
# ? Nov 16, 2010 18:22 |
|
litghost posted:? Janin posted:Use a schema file to auto-generate both the storage class/struct and its serialisation procedure.
|
# ? Nov 16, 2010 18:47 |
|
code:
if(hasRights(5)){...} What does '5' mean? Who knows! Well, actually there is an explanation about the bits in the rights-field in a comment near 'hasRights', but it's off-by-one. And for some reason it does not use the least significant bit at all This codebase is pretty
|
# ? Nov 16, 2010 19:36 |
|
Janin posted:Use a schema file to auto-generate both the storage class/struct and its serialisation procedure.
|
# ? Nov 16, 2010 20:03 |
|
Plorkyeran posted:You could also parse the header defining the struct and generate serialization code from that. Before you answer, remember that C++'s template system is Turing-complete.
|
# ? Nov 16, 2010 20:47 |
|
Wheany posted:Well, actually there is an explanation about the bits in the rights-field in a comment near 'hasRights', but it's off-by-one. And for some reason it does not use the least significant bit at all obviously it's a checksum.
|
# ? Nov 16, 2010 20:56 |
|
Janin posted:Would you rather spend 1) two hours writing a simple preprocessor or 2) two years writing a partial implementation of C++'s grammar? You could always pull the list of fields out of the debug metadata.
|
# ? Nov 16, 2010 21:01 |
|
Janin posted:Would you rather spend 1) two hours writing a simple preprocessor or 2) two years writing a partial implementation of C++'s grammar? I would like to point out, though, that parsing C++ does not have to require you writing the parser from scratch.
|
# ? Nov 16, 2010 22:57 |
|
Dear Penthouse: I never thought it would happen to me. For years, I've been reading sordid tales of the "for case" paradigm, but I never thought they actually happened! But today, I found this in svn... quote:Changeset 19314 for AutomatedUser code:
code:
code:
code:
|
# ? Nov 18, 2010 17:12 |
|
The for-case might be the least offensive part of that mess.
|
# ? Nov 18, 2010 17:35 |
|
npe posted:
Holy poo poo good game you win.
|
# ? Nov 18, 2010 18:03 |
|
npe posted:Dear Penthouse: Do VB switch-cases fall-through? If so, there are no words to describe the horror.
|
# ? Nov 18, 2010 18:09 |
|
That is truly tragic.code:
|
# ? Nov 18, 2010 18:35 |
|
I'm kind of surprised I've never come across this before. From the Zend framework:php:<? switch (true) { case (0 == $argc): break; case (1 <= $argc): $validator = array_shift($validatorInfo); case (2 <= $argc): $breakChainOnFailure = array_shift($validatorInfo); case (3 <= $argc): $options = array_shift($validatorInfo); default: $this->addValidator($validator, $breakChainOnFailure, $options); break; }?>
|
# ? Nov 18, 2010 18:37 |
|
Geekner posted:Do VB switch-cases fall-through? If so, there are no words to describe the horror. No, they don't.
|
# ? Nov 18, 2010 19:46 |
|
|
# ? May 16, 2024 09:17 |
|
FUCKIN' AJAX, MOTHERFUCKERS! code:
code:
Wheany posted:This codebase is pretty
|
# ? Nov 18, 2010 22:29 |