Simplify basic_sstring<> c_str()
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Refactor
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- cpp
- Domain
- performance
Research direction
Start by locating the basic_sstring<> c_str() implementation and its handle, then trace how whole-string and mid-string spans obtain their pointers. Simplify the handle access and preserve the special handling for spans that are already null terminated; done means the thread-safe sharing logic is removed for the stated cases without changing c_str() behavior.
Written by the indexing model from the issue text.
Description
The code in basic_sstring<> for handling c_str() is unnecessarily complex.
It seemed obvious when writing this that the c_str() value should be shared across the lifetime of the string and across threads, but given that the value is constant and that the vast majority of basic_sstring instances will be references to entire strings, having this extra thread safe logic to deal with sharing the c_str() value is not a good thing.
The logic should change, at a minimum, to:
- Store the c_str() value in the handle without using thread-safe mechanisms
- Retrieve the c_str() value from the handle without using thread-safe mechanisms
- If the basic_sstring<> represents the end of the string (meaning the whole string, or that the end of the span is the end of the base span), we know it's already null terminated, so store the pointer to the head of the current span in the handle
- Only otherwise, take action on dealing with a mid-string c_str()
It seems like a good idea to get rid of the shared state from the shared string, but this can be considered later.
- Dominant language
- C++
- Stars
- 2
- Forks
- 8
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Azure/m
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 1/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 1/5 Under an hour Newbie friendliness 84/100
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
AXERA-TECH/ax-llm#77 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
games-on-whales/wolf#509 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
bug-unconfirmed
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
NVIDIA/cuda-samples#453 ·