Developer forums (C::B DEVELOPMENT STRICTLY!) > Development
New projects "Custom Vars" tab
oBFusCATed:
--- Quote from: earlgrey on December 01, 2019, 01:31:33 pm ---> Performance ?
You have a supplementary filtering code, so evidently less preformance
--- End quote ---
I doubt someone would make 100 or 1000 variables, so performance is not that important here.
If you want performance you'll leave filtering to the callers or use a bitset, but returning new objects on the stack is massive performance problem (new/delete/copy are really expensive functions).
--- Quote from: earlgrey on December 01, 2019, 01:31:33 pm ---Something like this :
--- Code: ---virtual vector< CustomVar const & > VarGetAll(int _i_flags = eVarActive) const;
--- End code ---
I just didnt think at it >:(. I do this and I post on github so the code can be reviewed.
--- End quote ---
This API is really bad for performance...
earlgrey:
> I doubt someone would make 100 or 1000 variables
I know that's why I did add the flags and the filtering.
> This API is really bad for performance...
Yes ; rather like this :
--- Code: ---~ CompileOptionsBase.h ~
std::vector< CustomVar const & > & CompileOptionsBase::VarGetAll(int _i_flags = eVarActive) const;
--- End code ---
--- Code: ---~ CompileOptionsBase.cpp ~
static std::vector< CustomVar const & > m_VarGetAllResult;
...
std::vector< CustomVar const & > & CompileOptionsBase::VarGetAll() const
{
~ filter the vars, fill m_VarGetAllResult, and return reference to it ~
}
--- End code ---
The returned vector does not need to be const.
EDIT
This is wrong :
--- Code: ---static std::vector< CustomVar const & > m_VarGetAllResult;
--- End code ---
wont compile :
error: ‘struct std::_Vector_base<const CustomVar&, std::allocator<const CustomVar&> >::_Vector_impl’ has no member named ‘_M_finish’
std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
"forming pointer to reference type"
oBFusCATed:
I have no time to write the what is wrong with the last proposal, but this latest one is even worse.
Just leave the filtering to the client please.
Either you'll do it or I'll have to do it when I review your changes. 8)
earlgrey:
OK boss ;D
earlgrey:
You can have a look @ https://github.com/earlgrey-bis/obuscated.cb/commit/2b4a0cfa2463fce9f3e0aac1b9791d5a7500f2aa
Missing :
- full & correct handling of keyboard shortcuts.
- some code cleanup ( comments, ... )
Navigation
[0] Message Index
[*] Previous page
Go to full version