Closed ZevEisenberg closed 6 years ago
I got a great suggestion from @fcanas, @danielpunkass, and @mattmassicotte about avoiding thread-local storage: when constructing strings using styled(with:overrideParts:)
, in cases where we strip the final-character kerning attribute, add our own custom com.raizlabs.bonmot.kerningAttributeRemovedHere
attribute to the last character of the string. Then, in composed(of:baseStyle:separator:)
, look for that attribute, and if it's there and it's not the last item, reinstate the kerning attribute. I like this better than thread-local, so I'm going to take a crack at switching to this method.
Oh, and @mattmassicotte pointed out that what I probably wanted in the first place was queue-local storage, not thread-local storage. Good distinction to make!
The new method also has the nice bonus of working with any string created with styled(with:overrideParts:)
, instead of just those created with that method but only when passed to composed(of:baseStyle:separator)
directly. I see this as a win.
👋 I’ll have discussions about TLS any time!
Great work fixing this!
fixes #284