Ludovic 'Archivist'
which add to the space allocated to an std::String
NO, string doesn't inherit any virtual function or have any virtual functions
Anonymous
which take nothing, they are not even in vtables
it takes like 64 bytes if i recall
BinaryByter
however the offsets are still there
You win speed and a LOT of ease for maybe 100 bytes
Anonymous
they have other things
Anonymous
You win speed and a LOT of ease for maybe 100 bytes
BUT THOSE HUNDRED BYTES CAN BE USED FOR BETTER THINGS
Ludovic 'Archivist'
it takes like 64 bytes if i recall
neither in MSVC, nor in GCC stdlib, nor in Clang's, nor on intel's...
BinaryByter
this is wrong
BinaryByter
BUT THOSE HUNDRED BYTES CAN BE USED FOR BETTER THINGS
Hundred bytes? Thats not a lot and again, they help for speed
Ludovic 'Archivist'
Al you save is 16 bytes at most
BinaryByter
they help for ease of programming
BinaryByter
That way you know that you won't fuck up with your chars
BinaryByter
this is wrong
C is wayy harder than C++
BinaryByter
but it doesnt have more things than C++
BinaryByter
it doesnt make sense to use C
BinaryByter
@ollirz time for you to tell me why C is fine on embedded systems 😉
Anonymous
0000000000400650 <.plt>: 400650: ff 35 b2 09 20 00 pushq 0x2009b2(%rip) # 601008 <_GLOBAL_OFFSET_TABLE_+0x8> 400656: ff 25 b4 09 20 00 jmpq *0x2009b4(%rip) # 601010 <_GLOBAL_OFFSET_TABLE_+0x10> 40065c: 0f 1f 40 00 nopl 0x0(%rax) 0000000000400660 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED1Ev@plt>: 400660: ff 25 b2 09 20 00 jmpq *0x2009b2(%rip) # 601018 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED1Ev@GLIBCXX_3.4.21> 400666: 68 00 00 00 00 pushq $0x0 40066b: e9 e0 ff ff ff jmpq 400650 <.plt> 0000000000400670 <_ZNSaIcED1Ev@plt>: 400670: ff 25 aa 09 20 00 jmpq *0x2009aa(%rip) # 601020 <_ZNSaIcED1Ev@GLIBCXX_3.4> 400676: 68 01 00 00 00 pushq $0x1 40067b: e9 d0 ff ff ff jmpq 400650 <.plt> 0000000000400680 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1EPKcRKS3_@plt>: 400680: ff 25 a2 09 20 00 jmpq *0x2009a2(%rip) # 601028 <_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1EPKcRKS3_@GLIBCXX_3.4.21> 400686: 68 02 00 00 00 pushq $0x2 40068b: e9 c0 ff ff ff jmpq 400650 <.plt> 0000000000400690 <__gxx_personality_v0@plt>: 400690: ff 25 9a 09 20 00 jmpq *0x20099a(%rip) # 601030 <__gxx_personality_v0@CXXABI_1.3> 400696: 68 03 00 00 00 pushq $0x3 40069b: e9 b0 ff ff ff jmpq 400650 <.plt> 00000000004006a0 <_Unwind_Resume@plt>: 4006a0: ff 25 92 09 20 00 jmpq *0x200992(%rip) # 601038 <_Unwind_Resume@GCC_3.0> 4006a6: 68 04 00 00 00 pushq $0x4 4006ab: e9 a0 ff ff ff jmpq 400650 <.plt> 00000000004006b0 <_ZNSaIcEC1Ev@plt>: 4006b0: ff 25 8a 09 20 00 jmpq *0x20098a(%rip) # 601040 <_ZNSaIcEC1Ev@GLIBCXX_3.4>
Anonymous
there are so many more things
BinaryByter
there are so many more things
those are maybe 16 - 30 bytes
Anonymous
hold on the personality and unwind resume is not there
BinaryByter
Unfortunately yes
BinaryByter
I had to relearn C++
Anonymous
Anonymous
30
Anonymous
there are more then 30 bytes
BinaryByter
BinaryByter
Speed is wayy more critical than memory on today's machines
BinaryByter
in fact, it has always been
Anonymous
Speed is wayy more critical than memory on today's machines
it is however it is actually not much of a speedup then what is originally saved
Anonymous
it is faster to have homemade ones
Anonymous
i tend not to use strlen or anything like this
Anonymous
because i know the length from the read/recv operation
Zero
i'm 100 cool
Googled my name?
Anonymous
you can use that variable instead and do more complex processing without ever changing into a string
Kelvin
Googled my name?
i use net explorer
Anonymous
also sizeof(std::string) gives you 32 bytes of memory stored
Anonymous
irregardless of the size of the array
Anonymous
strlen?
length of a null terminated
BinaryByter
Roman
8)
BinaryByter
length of a null terminated
std::string::size(); whats the O of that one?
BinaryByter
strlen?
whats the O of that one?
Ludovic 'Archivist'
also sizeof(std::string) gives you 32 bytes of memory stored
Yeah, noticed gcc uses a trick for optimization that uses 8 more bytes
Ludovic 'Archivist'
BinaryByter
"not too much of a speedup"
Ludovic 'Archivist'
Ludovic 'Archivist'
it is however it is actually not much of a speedup then what is originally saved
for a string longer than 64 bytes, the speedup is far noticeable
Anonymous
whats the size of a pointer on 86x64?
8 bytes so that means 24 bytes are string stuff
Ludovic 'Archivist'
BinaryByter
isnt that acceptable?
Anonymous
no
Anonymous
because it is complete shit
Anonymous
and useless
Anonymous
there are faster ways to process just using char*
BinaryByter
no
so you prefer having a slow string that takes n bytes instead of having a fast wrapper for that slow string that takes n + 32 bytes?
BinaryByter
it is not a slow string
char* is slower than std::string
Anonymous
the functions are exactly the same
Anonymous
the only case is strlen
BinaryByter
it is not
how do you get the size of a string?
Anonymous
but strlen should NOT BE USED
BinaryByter
the only case is strlen
every other function depends on the length of the string
Anonymous
how do you get the size of a string?
you get the length when you read it in
Anonymous
and then?
you keep that length
Ludovic 'Archivist'
you get the length when you read it in
yet printf uses it, like most of the standard C lib
Anonymous
and just update it
BinaryByter
you keep that length
Isnt that what std::string encurages you to do/does?
MᏫᎻᎯᎷᎷᎬᎠ
.
Ludovic 'Archivist'
Isnt that what std::string encurages you to do/does?
Let it slide, this guy have 0 practical sense, he is a C crazy guy like the Torvalds