phobos icon indicating copy to clipboard operation
phobos copied to clipboard

add std.conv.hexData()

Open WalterBright opened this issue 4 years ago • 6 comments

This is an alternative to hexString based on usage feedback from Dunnhumby.

  1. does not use templates so it does not have problems with very large strings nor object file bloat
  2. wstring and dstring are not supported, as it is hard to imagine a compelling use case for them
  3. ubyte[] is returned instead of string as it only makes sense for hex data to initialize ubyte arrays, not strings
  4. return value is immutable so it can be used to initialize global tables with need for casting
  5. works with any string - no error cases. Non-hex digits are treated as separators
  6. it is intended to be used in CTFE code as a better replacement for the removed x string core language feature
  7. it has no dependencies on anything else, and so can be cut-pasted into user code that does not rely on Phobos.

It is designed to work with https://github.com/dlang/DIPs/pull/177 although that is not required for hexData() to be useful.

WalterBright avatar Oct 03 '19 09:10 WalterBright

Thanks for your pull request, @WalterBright!

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub fetch digger
dub run digger -- build "master + phobos#7211"

dlang-bot avatar Oct 03 '19 09:10 dlang-bot

The buildkite error is:

generated/linux/release/64/benchmark.o:benchmark/runbench.d:function _D3std5regex8internal9kickstart__T7ShiftOrTaZQl6__ctorMFNcNeKSQCiQChQCe2ir__T5RegexTaZQjAkZSQDmQDlQDiQDc__TQCvTaZQDb: error: undefined reference to '_D3std5range__T12assumeSortedVAyaa6_61203c3d2062TAkZQBlFNaNbNiNfQpZSQCoQCn__T11SortedRangeTQBqVQCna6_61203c3d2062ZQBl'

which has nothing to do with this PR.

WalterBright avatar Oct 03 '19 19:10 WalterBright

Yeah the druntime benchmark check uses a wrong version of phobos.

wilzbach avatar Oct 03 '19 19:10 wilzbach

@wilzbach so what's the fix?

WalterBright avatar Oct 05 '19 06:10 WalterBright

Nothing, as Buildkite is not required to pass to pull. You should double-check that the benchmark is the only failure though.

thewilsonator avatar Oct 05 '19 06:10 thewilsonator

@WalterBright a rebase will most likely fix the buildkite error and then the autotester will be green. However, you still need to address @CyberShadow 's review.

RazvanN7 avatar Apr 21 '21 09:04 RazvanN7