Small String Optimization in C++

preview_player
Показать описание


This video is sponsored by Hostinger
Рекомендации по теме
Комментарии
Автор

normal person:
if(_Cout < MAX_SIZE)
STL programers:
if(_Cout < _Mypair._Myval2._Myres)
where _Myres is _Container_base value of type size_type that is set up as _BUF_SIZE-1 where _BUF_SIZE is static const expression and in this case it is goning to be 1 if 16/sizeof(value_type) < 1 or where _string_val of type _val_types ... Okay. I got bored.

Lord
Автор

First of all: Yes more C++!


Secondly, Loving the new small editing over silly talks and expressions, enjoyed this one alot!

iDizzasTeR
Автор

I just don't understand how Cherno learned C++ without his own playlist

Tofu-ypso
Автор

The best C++ playlist on the internet.

ShivamJha
Автор

*My takeaways:*
1. Small strings do not use heap memory 3:45
2. The length definition of small strings varies based on the version of C++ standard library 4:35
3. Check out the definition of string to find out the length definition of small strings 6:29
4. Test the length definition of small strings in code 9:19

leixun
Автор

That was awesome, I use strings a lot and did not know in Release mode they get treated differently. Some people use debug config everywhere (even for production), I do not, there is more stuff going on in debug compiling. Here is one case of that.

glee
Автор

I've started learning C++ for a couple of months now, and I tend to stay off the internet cause de negativity and ppl yelling at me cause I'm doing stupid stuff lol.
But this channel thought me more than any forum/page I got in so far.
Awesome content!

chicoern
Автор

how could anybody make sense of that library?

MrTrollland
Автор

Wow, this is some impressive stuff. Crazy how you deduced this simply through analysing std implementation. I certainly have a way to go...

bigboiblue
Автор

Thank you Cherno for making such a great videos! Data structures and patterns would be absolutely amazing topic!
Your lessons were so helpful when learned programming, now I am working as a C programmer and still educating myself by watching your C++ series.

aleksandrskutins
Автор

I'm pretty sure strings are half of why we're here today. The other half is of course the math side of things. Like how the history of computer science started as mostly doing science calculations, but the guys at Bell Labs really wanted a word processor because documents is a huge part of our daily life. Professors and "regular" people needed the ability to process text and oh the kind of hacks they came up with despite the ridiculous limitations of memory. I believe they started reading only bits of the text into memory at time and then pipelining all kinds of small programs to get to the result they wanted. Ended up at AWK I suppose, and happened to also invent techniques that would help a lot in developing computer science. Leading to figuring out the proprietary printer stuff to allow access to better quality printed documents and eventually leading to pdf. Imagine the world without computer text editors and printing digital documents.

Yupppi
Автор

I can't remember the name of the talk. But there is a really good cppcon talk by Andrei Alexandrescu about his implementation of Facebook's standard library string fb::string which is a 24byte strict with a 23 char sso

JackPunter
Автор

Good Stuff! I just stumbled into an alternate reality version of this same concept a week ago. I am trying to write a compiler and stuff like this is like gold.

bradmccoy
Автор

Why is the standard C++ library written so weirdly? All that snake-case and camel-case mixed into one.

VivekYadav-dsoz
Автор

Great video!
What do we want? 12:30 Design Patterns!

brunooliveirasoares
Автор

The reality is, that using small strings although it's an optimisation still isn't as efficient as a const char* which is about as efficient as it gets because it'll live in the resource section of the executable. Unless you NEED the dynamic functionality and nature of std::string, you should prefer const char* over std::string especially if your string isn't dynamic, although you do need to know it's length.

thewelder
Автор

std::string_view vs std::string would make a cool video

bobbybaker
Автор

Could you make a video about std::move and Return Value Opimiztion (Copy elision) explaining the conecpts of rvalues, lvalues, perfect forwarding and typical programming idiums for best performing code considering these concepts?

DerThomyLP
Автор

This was great! Thank you for explaining some of the complexity of the STL implementation. I also really enjoy this video and the last you posted in this series.

drakejohnson
Автор

You should look at fbstring in Facebook's folly library. It has a 23 character limit. I think it may be the most optimized string implementation in existence.

adecfdcefecdadcad