Re: [Oorexx-devel] An alternative algorithm for x2c()

2019-04-18 Thread Mike Cowlishaw
case 'A': tmp=10; break; case 'B': tmp=11; break; case 'C': tmp=12; break; case 'D': tmp=13; break; case 'E': tmp=14; break; case 'F': tmp=15; break; Also need to add cases 'a' through 'f'? ___

Re: [Oorexx-devel] An alternative algorithm for x2c()

2019-04-18 Thread Mark L. Gaubatz via Oorexx-devel
Two additional quick notes: 1. The static const arrays may be const only when dealing with a fixed character set. For some products I’ve worked on, the initialization of the arrays occurs during startup and after a character set option has been selected. 2. (len % 2 == 1), while

Re: [Oorexx-devel] An alternative algorithm for x2c()

2019-04-18 Thread Mike Cowlishaw
Not sure if it would be any faster, but maybe neater to simplify some of the below along the lines of: case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': tmp=hexData[i-1]-'0'; break; (I'd also make the increments of i

[Oorexx-devel] An alternative algorithm for x2c()

2019-04-18 Thread Rony G. Flatscher
While experimenting a little bit with C code to decode hex strings I came up with the following code: boolean hex2char(CSTRING hexData, size_t len, char *data) { if (len % 2 == 1) // not an even number of hex characters { data[0]='\0'; return

Re: [Oorexx-devel] An alternative algorithm for x2c()

2019-04-18 Thread Mark L. Gaubatz via Oorexx-devel
Rony: Too many comparisons are being done from a performance perspective; a minimal comparison for validation and no comparison for translation is the fastest. Actual translation should be done with a pair of 256-byte arrays for speed AND portability across character sets. Speed varies