![]() |
#11 | |||||
Knight
Join Date: Apr 2007
Posts: 726
![]() |
Quote:
Quote:
Quote:
Quote:
![]() Quote:
Last edited by Bandobras; December 21, 2007 at 17:47. |
|||||
![]() |
![]() |
![]() |
#12 | ||||
Knight
Join Date: Apr 2007
Posts: 590
![]() |
Quote:
Unfortunately, the red-black binary tree was backing a std::set which I needed the deduplication of keys effect from. This process was moved from the main flygram suite to a moderately configurable data table distiller.) The data in these nodes was a pair of long doubles -- trivial construction/destruction. I'm pretty sure that less than one second went into everything other than juggling memory management. Quote:
|
||||
![]() |
![]() |
![]() |
#13 |
Knight
Join Date: Apr 2007
Posts: 590
![]() |
Takkaria: yes or no on the proposed patch? (Would need to discuss structure on angband-dev if yes. There are some low-level dependencies that need consideration in the design stage.)
|
![]() |
![]() |
![]() |
#14 |
Veteran
Join Date: Apr 2007
Posts: 1,950
Donated: $40
![]() |
I'm willing to see people's ideas, but I'm not committing yet. If you put together an example of the kind of code it'll result in, then I can give you a much better answer.
|
![]() |
![]() |
![]() |
#15 | ||
Knight
Join Date: Apr 2007
Posts: 590
![]() |
Quote:
The concrete gains I've seen so far in prototype: * using C_COPY and C_WIPE in a few places from z-virt.h * iterating over loops controlled by array size to future-proof load/save code and the flag abstraction code in a few places
__________________
Zaiband: end the "I shouldn't have survived that" experience. V3.0.6 fork on Hg. Zaiband 3.0.10 ETA Mar. 7 2011 (Yes, schedule slipped. Latest testing indicates not enough assert() calls to allow release.) Z.C++: pre-alpha C/C++ compiler system (usable preprocessor). Also on Hg. Z.C++ 0.0.10 ETA December 31 2011 |
||
![]() |
![]() |
![]() |
#16 | |
Prophet
Join Date: Apr 2007
Location: Seattle, WA
Posts: 6,726
Donated: $40
![]() |
various people write:
Quote:
In particular, what happens if you want to match more than one flag variable at a time? You may want to do things logically like: flags & (RCONF | RCHAOS) /* Example from NPP */ You can't do this if the high order bits and low order bits are dependent the way they would be in your example. You just can't OR together array indexes to get valid array indexes. They are ordinal numbers, not orthogonal bits. |
|
![]() |
![]() |
![]() |
#17 |
Knight
Join Date: Apr 2007
Posts: 726
![]() |
The original example wasn't mine, but I couldn't ignore that one:
This is one of the many bad things induced by bit arithmetic. Such coding is very error prone, especally when you extend your variant. If the 'flags' bitfields is not the one variable (of a few) that holds the RCONF and RCHAOS bits, you have an error that people may not notice for years. If the RCONF and RCHAOS bits land at opposite sides of a bitfiled boundary you can get another error and you cannot write the code in this way at all, so you get irregular code. This should be written Code:
object_has_flag(o_ptr, F_CONF) && object_has_flag(o_ptr, F_CHAOS) Edit: corrected my code ![]() Edit2: the F_CONF, etc. flags can be the same constant for object flags, monster flags, character flags, etc. because there is plenty of space in a bit vector, so no problem with unused bits. The macros can catch inappropriate flags, though, to point out errors, or they can translate the flags to save space in the bit vector, when really needed. Edit3: actually, bit vectors are not necessary for the high-level approach I proposed above, bietfields would do, with much messier macros, but even the following mid-level code is quite safe: Code:
check_flag(vecor, F_CONF) && check_flag(vector, F_CHAOS) Last edited by Bandobras; December 22, 2007 at 14:36. |
![]() |
![]() |
![]() |
#18 | ||
Knight
Join Date: Apr 2007
Posts: 590
![]() |
Quote:
Quote:
If I was making the final decision for V (I'm not, I merely am willing to provide patching as a code experiment), based on what I'm seeing in prototype I'd stop with: * sanity-checking the flags for low-level dependencies with assert() [V probably needs this regardless] * make a policy decision on whether converting to bitvector arrays is worth future-proofing, and C_COPY/C_WIPE applicability. * making a policy decision on whether the trivial syntax change for newbie bit test/set/update is worth supporting two macro sets. If it is, make a policy decision on whether to use enum or #define for the flag index version. C dictates going from flag index to bitmap. See angband-dev for what the #define changes will look like for object flags in the enum case. * Design requirement: leave in the bitvector math capability on array elements, as it's moronic to ditch that. In C++ with Boost libraries, "just" use a template function with two parameters and a conditional type definition to detect whether or not the two flags are in the same bucket. You lose all C++ compilers too archaic for Substitution Failure Is Not An Error (SFINAE). [While not relevant to this construction, a number of Boost libraries do imply not using MSVC++'s ISO-breaking Safe STL.] Last edited by zaimoni; December 22, 2007 at 14:59. |
||
![]() |
![]() |
![]() |
#19 | ||
Knight
Join Date: Apr 2007
Posts: 590
![]() |
Quote:
Quote:
Last edited by zaimoni; December 22, 2007 at 15:40. |
||
![]() |
![]() |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Display Modes | |
|
|