Skip to content

Петров Николай#37

Open
18thday wants to merge 63 commits intopsds-cpp:mainfrom
TookTM:main
Open

Петров Николай#37
18thday wants to merge 63 commits intopsds-cpp:mainfrom
TookTM:main

Conversation

@18thday
Copy link
Contributor

@18thday 18thday commented Jan 19, 2026

No description provided.

// Состояние буфера

bool RingBuffer::Empty() const noexcept {
return !full_ && (head_ == tail_);
Copy link
Contributor Author

@18thday 18thday Jan 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

как будто размер с 0 сравнивать эффективно

}

bool RingBuffer::Full() const noexcept {
return full_;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

как будто размер с cpacity сравнивать эффективно, и можно не хранить поле, тем более, если вспомнить про выравнивание, то мы помимо одного байта ещё имеем большое выравнивание для хранения поля

bool Stack::Pop(){
if (stack.empty()){
return false;
} else{
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

else создает лишнюю вложенность

}
}

int& Stack::Top(){
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

не хватает пробела перед {

stack.clear();
}

void Stack::Swap(Stack& stack2){
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

other принято использовать в качестве имени

Copy link
Contributor Author

@18thday 18thday left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TookTM отметил следующие моменты:

  • постфиксный инкремент использует вместо префиксного
  • дублирование кода
  • лишняя вложенность условий
  • неоптимальное сравнение Queue с двойным копированием
  • лишние поля в RingBuffer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants