Wladimir J. van der Laan ad823178e8
Merge #12704: base58: use map instead of strchr() when decode
bcab47b use base58 map instead of strchr() (Kevin Pan)

Pull request description:

  Use array map instead of find string position.

  Test code snippet:

  ```cpp

  #include <assert.h>
  #include <stdint.h>
  #include <stdio.h>
  #include <stdlib.h>

  #include <string>

  int main(int argc, const char * argv[]) {

    static const char* pszBase58 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
    static const int8_t mapBase58[] = {
      -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,
      -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,
      -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,
      -1, 0, 1, 2, 3, 4, 5, 6,  7, 8,-1,-1,-1,-1,-1,-1,
      -1, 9,10,11,12,13,14,15, 16,-1,17,18,19,20,21,-1,
      22,23,24,25,26,27,28,29, 30,31,32,-1,-1,-1,-1,-1,
      -1,33,34,35,36,37,38,39, 40,41,42,43,-1,44,45,46,
      47,48,49,50,51,52,53,54, 55,56,57,-1,-1,-1,-1,-1,
    };

    const std::string b58Str(pszBase58);

    for (size_t i = 0; i < b58Str.length(); i++) {
      const char *ch = strchr(pszBase58, b58Str[i]);
      printf("%d - %d\n", ch - pszBase58, mapBase58[(uint8_t)b58Str[i]]);
      assert(ch - pszBase58 == mapBase58[(uint8_t)b58Str[i]]);
    }

    assert(mapBase58['1'] == 0);
    assert(mapBase58['z'] == 57);

    /** All alphanumeric characters except for "0", "I", "O", and "l" */
    assert(mapBase58['0'] == -1);
    assert(mapBase58['I'] == -1);
    assert(mapBase58['O'] == -1);
    assert(mapBase58['l'] == -1);

    return 0;
  }

  ```

Tree-SHA512: c28376dc8c92cc4a770c3282db4a568ae5f5a08e27f714183eb3d8755421dc7aa11d7b45afa55e70eba46565f378062aac53dc8f150eeeab12ce7b5db5af89c5
2018-03-22 10:00:10 +01:00
..
2018-03-21 10:54:17 +01:00
2018-02-16 08:59:28 -05:00
2018-03-21 10:54:17 +01:00
2018-03-20 13:07:17 -04:00
2018-03-21 08:34:44 +02:00
2017-09-29 16:02:39 +02:00
2018-03-21 08:34:44 +02:00
2018-02-10 09:55:54 -05:00
2018-03-21 18:04:04 -04:00
2018-03-06 21:52:53 +01:00
2018-03-21 10:54:17 +01:00
2018-03-21 11:57:57 +08:00
2018-02-11 10:48:15 +01:00
2018-03-06 19:52:19 +00:00
2018-03-06 19:52:19 +00:00
2018-03-13 17:04:31 -07:00
2018-02-27 11:42:06 -08:00
2018-03-21 08:34:44 +02:00
2018-03-21 08:34:44 +02:00
2018-03-13 17:04:31 -07:00
2018-03-13 19:12:35 +01:00
2018-01-23 13:16:56 -05:00
2018-01-10 20:55:41 -10:00
2018-03-14 23:10:39 -07:00
2018-03-21 08:34:44 +02:00
2018-03-21 08:34:44 +02:00
2018-03-06 19:52:19 +00:00
2018-01-28 13:21:25 +01:00
2018-03-21 08:34:44 +02:00
2018-01-09 08:59:21 -05:00
2018-03-21 08:34:44 +02:00
2018-03-21 08:34:44 +02:00
2018-03-06 20:28:08 -08:00
2018-03-21 08:34:44 +02:00
2018-03-06 19:52:19 +00:00