Don't use std::shared_ptr in CStrIntern #6965

Merged
phosit merged 1 commits from phosit/0ad:Don't_use_shared_ptr_in_CStdIntern into main 2024-08-25 11:58:27 +02:00
Member

Now there is less allocation and reference counting.

Continuation of https://code.wildfiregames.com/D5155

Now there is less allocation and reference counting. Continuation of https://code.wildfiregames.com/D5155
phosit added 1 commit 2024-08-24 12:21:56 +02:00
Imported from Phab
Some checks reported warnings
0ad-freebsd/pipeline/pr-main This commit is unstable
0ad-windows/pipeline/pr-main This commit is unstable
0ad-checkrefs/pipeline/pr-main This commit looks good
0ad-macos/pipeline/pr-main This commit is unstable
0ad-linux/pipeline/pr-main This commit looks good
8d48b161ee
Member

A commit message "Imported from Phab" is no good :)

A commit message "Imported from Phab" is no good :)
Author
Member

A commit message "Imported from Phab" is no good :)

Why?
Should it be "Don't use std::shared_ptr in CStrIntern" again?
Normaly a branch starts as "Initial commit". That isn't much better.

> A commit message "Imported from Phab" is no good :) Why? Should it be "Don't use std::shared_ptr in CStrIntern" again? Normaly a branch starts as "Initial commit". That isn't much better.
Member

The branch name and the title and message of the pull request are irrelevant for how the commit will look like once merge.

You can fix the commit message with "git commit --amend", then check how it looks like with "git log".

The branch name and the title and message of the pull request are irrelevant for how the commit will look like once merge. You can fix the commit message with "git commit --amend", then check how it looks like with "git log".
Owner

With the rebase workflow "Imported from Phab" will be committed to main. There is no squash. Nor commit renaming. You have to do that on the branch.

With the rebase workflow "Imported from Phab" will be committed to main. There is no squash. Nor commit renaming. You have to do that on the branch.
Author
Member

Thanks for the explanation

Thanks for the explanation
phosit force-pushed Don't_use_shared_ptr_in_CStdIntern from 8d48b161ee to 89750f84e6 2024-08-24 14:32:55 +02:00 Compare
sera reviewed 2024-08-24 14:52:59 +02:00
@ -108,3 +111,1 @@
std::shared_ptr<CStrInternInternals> internals = std::make_shared<CStrInternInternals>(str, len);
g_Strings.insert(std::make_pair(internals->data, internals));
return internals.get();
return &g_Strings.insert({str, {str, len}}).first->second;
Member

maybe make the return type a reference to signal doesn't need delete and is never null?

maybe make the return type a reference to signal doesn't need delete and is never null?
Author
Member
I've done that in https://code.wildfiregames.com/D5157
Member

This patch here returns a pointer tho

This patch here returns a pointer tho
Member

I see, someone wasn't a big fan of it :)

I see, someone wasn't a big fan of it :)
phosit force-pushed Don't_use_shared_ptr_in_CStdIntern from 89750f84e6 to 318c0aecd2 2024-08-24 16:31:53 +02:00 Compare
phosit force-pushed Don't_use_shared_ptr_in_CStdIntern from 318c0aecd2 to 45d51b7cf6 2024-08-24 16:38:21 +02:00 Compare
phosit added the
Theme
Core engine
label 2024-08-24 17:07:38 +02:00
sera approved these changes 2024-08-24 20:26:46 +02:00
phosit merged commit 62c0080e1b into main 2024-08-25 11:58:27 +02:00
phosit deleted branch Don't_use_shared_ptr_in_CStdIntern 2024-08-25 11:58:27 +02:00
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: 0ad/0ad#6965
No description provided.