Open
Conversation
Charonxin
reviewed
May 21, 2024
| } | ||
| } | ||
| else { | ||
| counter->inc_count (); |
Collaborator
There was a problem hiding this comment.
Why this statement in two branchs looks like same?
Contributor
Author
There was a problem hiding this comment.
the only difference is null checking
c8f7dc6 to
bd8a506
Compare
Charonxin
approved these changes
May 22, 2024
because pointer does not need to know which type is hold at body.
fix compile error on blackbox
b28aadf to
71a7e17
Compare
71a7e17 to
e79e91f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
This pr replaces
ABSTRUCT_XXXandCONCRETE_XXXwith unified reference counted pointer, as a replacement of #263. Similar works can be found at https://github.com/mgubi/texmacs/tree/restructureConcrete struct (defined by
CONCRETE,*_repand so on) is used as reference counter. For example, type T is implemented as two class: T_rep handles properties of given type, and T handles reference and counter of references to T_rep. When T is assigned, only reference is assigned with counter in/decreased.Works
tm_new<xxx>string_u16withcounted_ptrblackboxwithcounted_ptrtm_ostreamwithcounted_ptrQuestion
Can managed pointer point to a literal type?
Currently there is no way to get address of literal object, especially when the object is created from inside of other function, such as constructor of managed pointer. See 为什么很多std容器不能作为编译期常量? - 暮无井见铃的回答 - 知乎 for more information.
Why managed pointer holds two pointers, even though pointer of instance can be retrieved from pointer of reference counter?
Performance. Multilevel pointer and member is less effective than single cached pointer.
Are there differences between template and non-template subclass of managed pointer?
Sadly yes, there are some significant difference:
basealias type must be exploited manually to subclass ofcounted_ptr;makemethod.Performance
Construction is faster, but access is a bit slower:
Before
construct string_u16construct string_u16 with contentequality of stringequality of larger stringcompare stringcompare larger stringslice stringslice string with larger range(Unstable with ~1,595,528.7 iters. IncreaseminEpochIterationsto e.g. 15955287)concat stringappend string(Unstable with ~217,087.1 iters. IncreaseminEpochIterationsto e.g. 2170871)After
construct string_u16construct string_u16 with contentequality of stringequality of larger stringcompare stringcompare larger stringslice stringslice string with larger range(Unstable with ~3,444,501.7 iters. IncreaseminEpochIterationsto e.g. 34445017)concat stringappend string(Unstable with ~217,087.1 iters. IncreaseminEpochIterationsto e.g. 2170871)