JCodePeace
I used to Lazarus for creating simple UI-applications
Talula
Lazarus is more similar to Delphi
It's same... but for every few differences, Delphi is bit simpler due to these small differences.
Talula
Cross compiled GUI applications, like if I want to develop for Windows/Linux and Mac and don't want to write any extra code... I do it in Lazarus.
JCodePeace
Not always
Nandan
Im ,,...
2foryou
why can't I have std::string with capacity exactly 12? it goes only up to 15? is there a way to overwrite it? thanks
BinaryByter
std::string uses sso
BinaryByter
this means that the variables inside of std::string are used instead of the char* buffer
BinaryByter
and the data members of std::string are exactly 16 bytes
@oleg
hi guys! tell me please, which is better?
@oleg
uint32_t _swap_u32(uint8_t *data) { union { uint32_t u32; uint8_t u8[4]; } result; result.u8[0] = data[2]; result.u8[1] = data[3]; result.u8[2] = data[0]; result.u8[3] = data[1]; return result.u32; } vs uint32_t _swap_u32(uint8_t *data) { return (uint32_t)data[1] << 24)|(uint32_t)data[0] << 16)|(uint32_t)data[2] << 8)|(uint32_t)data[3]); }
BinaryByter
the first one is invalid
@oleg
no! is valid)
BinaryByter
undefined behaviour
BinaryByter
BinaryByter
https://en.cppreference.com/w/cpp/utility/variant
BinaryByter
use this btw
BinaryByter
uint32_t swap_u32(uint8_t *data) { return *reinterpret_cast <uint32_t*> (data); }
@oleg
different byte order
Anonymous
hi code mates
Anonymous
did someone build chromium from source ?
BinaryByter
different byte order
dafaq what tasks makes you use this weird byte order?
Anonymous
I wanna change default javascript functions.
@oleg
dafaq what tasks makes you use this weird byte order?
I receive this bytes from serial port
@oleg
From device
@oleg
On the microcontroller
Anonymous
You mean chromium OS?
Dima
Lol
Anonymous
What happened?
BinaryByter
dafaq
Ariana
I wanna change default javascript functions.
Its pretty simple to do, the source is quite neat
Anonymous
wait
BinaryByter
wait
yea
BinaryByter
xD
Anonymous
you say it is a swap but this is not a swap
Anonymous
why are you saying it is?
Anonymous
second one is the faster way for most microcontrollers actually
Anonymous
the first one is invalid
also this is false
Anonymous
that first one will work
BinaryByter
won't it be UB?
Anonymous
nope because he uses the union still in the lifetime
BinaryByter
Oh
Anonymous
I'd oppose
nope it is the fastest actually and most portable
@oleg
but platform dependent
@oleg
?
Anonymous
but platform dependent
you are using a microcontroller right?
BinaryByter
nope it is the fastest actually and most portable
the union approach is just an array acces, the bitshift one uses bitshifts which are slow
@oleg
yes
BinaryByter
unless the compiler optimizes them out
@oleg
esp8266
Anonymous
esp8266
EW XTENSA
Anonymous
do the xor way
Anonymous
why would it be platform dependant?
@oleg
different byte order
Anonymous
?
BinaryByter
he's talking about endian-ness
@oleg
endianness, yes)
@oleg
i speak english very bad, sorry)
Anonymous
i do not understand
Anonymous
what is the issue?
BinaryByter
he's worrying about endianness
Anonymous
unless the compiler optimizes them out
well with arm cpus a shift is typically encoded inside a and or or instruction
Anonymous
so that is going to be around 4-8 instructions
Anonymous
the other one would be a similar situation with 4 just for anding
Anonymous
now there is a way of tricking the system into just doing 8 bit operations
Anonymous
which would be the absolute fastest
Anonymous
because that one will be array accesses
BinaryByter
Anonymous
only issue is you forgot a ( after uint32_t
BinaryByter
number of instruction != speed
cmp is as slow as 20 adds