Conversation
| return Erase(Begin() + n0, Begin() + n1); | ||
| } | ||
|
|
||
| bool LLBC_Array::EraseSwap(LLBC_Array::Obj* o, bool releaseObj) |
There was a problem hiding this comment.
建议统一风格:
LLBC_Array::Obj* o -> LLBC_Array::Obj *o
|
|
||
| bool LLBC_Array::EraseSwap(LLBC_Array::Obj* o, bool releaseObj) | ||
| { | ||
| if (UNLIKELY(o == nullptr)) { |
|
|
||
| for (difference_type i = 0; i < _size; ++i) | ||
| { | ||
| if (_objs[i] == o) { |
| // Note: EraseSwap does not preserve element order, which is acceptable for AutoReleasePool | ||
| if (!_arr->EraseSwap(o, false)) | ||
| { | ||
| LLBC_SetLastError(LLBC_ERROR_NOT_FOUND); |
There was a problem hiding this comment.
这里待讨论,是不是EraseSwap返回值是int,这里就不需要重复setLastError了
There was a problem hiding this comment.
保留吧. 外层不知道EraseSwap内部细节的情况, 主动设置setLastError能确保有对应的错误信息
There was a problem hiding this comment.
追加一具评论:Array::UnstableErase()返回是bool也可以,更易使用,但里面其实已经设置了last errro,此处重复设置,需要修正
| if (UNLIKELY(!_head)) | ||
| { | ||
| LLBC_SetLastError(LLBC_ERROR_NOT_FOUND); | ||
| return LLBC_FAILED; |
There was a problem hiding this comment.
有点多余,下面for循环里面判断包括了这个case了
| _objs[lastIdx] = nullptr; | ||
| --_size; | ||
|
|
||
| LLBC_SetLastError(LLBC_ERROR_SUCCESS); |
There was a problem hiding this comment.
好像有点多余,成功应该不需要SetLastError了
| * Erase single object using swap-and-pop strategy (O(1) removal). | ||
| * Note: This method does NOT preserve element order. | ||
| */ | ||
| bool EraseSwap(Obj *o, bool releaseObj); |
There was a problem hiding this comment.
建议命名更容易理解:UnstableErase(Obj *o, bool releaseObj)
| _objs[i]->Release(); | ||
|
|
||
| // Swap-and-pop: swap with last element and decrement size | ||
| // This achieves O(1) removal instead of O(n) memmove |
|
|
||
| _arr->Erase(o, false); | ||
| // Use EraseSwap for O(1) removal (swap-and-pop strategy) | ||
| // Note: EraseSwap does not preserve element order, which is acceptable for AutoReleasePool |
| // Note: EraseSwap does not preserve element order, which is acceptable for AutoReleasePool | ||
| if (!_arr->EraseSwap(o, false)) | ||
| { | ||
| LLBC_SetLastError(LLBC_ERROR_NOT_FOUND); |
There was a problem hiding this comment.
追加一具评论:Array::UnstableErase()返回是bool也可以,更易使用,但里面其实已经设置了last errro,此处重复设置,需要修正
Co-authored-by: cw7180 <1127426279@qq.com>
Comment out the conditional check for pull request repository.
Updated curl command to use verbose mode for debugging.
Removed AI review response handling and comment posting steps.
#508) * feat: 优化 BasicString 中 vsnprintf 使用次数, 第一次使用 format string buffer 承接, 如果不需要 resize, 直接 memory copy 到目标 buffer, 减少第二次 vsnprintf 带来的 O(n) 扫描开销. #419 * feat: 优化 BasicString 中 vsnprintf 使用次数, 第一次使用 format string buffer 承接, 如果不需要 resize, 直接 memory copy 到目标 buffer, 减少第二次 vsnprintf 带来的 O(n) 扫描开销. #419
Uplevel your code reviews with CodeRabbit ProCodeRabbit ProIf you like this project, please support us by purchasing the Pro version. The Pro version has advanced context, superior noise reduction and several proprietary improvements compared to the open source version. Moreover, CodeRabbit Pro is free for open source projects. |
There was a problem hiding this comment.
Files selected (5)
- .github/workflows/linux-build.yml (1)
- llbc/include/llbc/core/objbase/Array.h (1)
- llbc/src/core/objbase/Array.cpp (1)
- llbc/src/core/objbase/AutoReleasePool.cpp (1)
- llbc/src/core/objbase/AutoReleasePoolStack.cpp (1)
Files not summarized due to errors (5)
- .github/workflows/linux-build.yml (nothing obtained from openai)
- llbc/include/llbc/core/objbase/Array.h (nothing obtained from openai)
- llbc/src/core/objbase/Array.cpp (nothing obtained from openai)
- llbc/src/core/objbase/AutoReleasePool.cpp (nothing obtained from openai)
- llbc/src/core/objbase/AutoReleasePoolStack.cpp (nothing obtained from openai)
Files not reviewed due to errors (5)
- llbc/include/llbc/core/objbase/Array.h (no response)
- llbc/src/core/objbase/Array.cpp (no response)
- llbc/src/core/objbase/AutoReleasePoolStack.cpp (no response)
- .github/workflows/linux-build.yml (no response)
- llbc/src/core/objbase/AutoReleasePool.cpp (no response)
Review comments generated (0)
- Review: 0
- LGTM: 0
Tips
Chat with
CodeRabbit Bot (@coderabbitai)
- Reply on review comments left by this bot to ask follow-up questions. A review comment is a comment on a diff or a file.
- Invite the bot into a review comment chain by tagging
@coderabbitaiin a reply.
Code suggestions
- The bot may make code suggestions, but please review them carefully before committing since the line number ranges may be misaligned.
- You can edit the comment made by the bot and manually tweak the suggestion if it is slightly off.
Pausing incremental reviews
- Add
@coderabbitai: ignoreanywhere in the PR description to pause further reviews from the bot.
No description provided.