@@ -1747,15 +1747,6 @@ pack_bits(PyObject *input, int axis, char order)
17471747static  PyObject  * 
17481748unpack_bits (PyObject  * input , int  axis , PyObject  * count_obj , char  order )
17491749{
1750-     static  int  unpack_init  =  0 ;
1751-     /* 
1752-      * lookuptable for bitorder big as it has been around longer 
1753-      * bitorder little is handled via byteswapping in the loop 
1754-      */ 
1755-     static  union  {
1756-         npy_uint8   bytes [8 ];
1757-         npy_uint64  uint64 ;
1758-     } unpack_lookup_big [256 ];
17591750    PyArrayObject  * inp ;
17601751    PyArrayObject  * new  =  NULL ;
17611752    PyArrayObject  * out  =  NULL ;
@@ -1841,22 +1832,6 @@ unpack_bits(PyObject *input, int axis, PyObject *count_obj, char order)
18411832        goto fail ;
18421833    }
18431834
1844-     /* 
1845-      * setup lookup table under GIL, 256 8 byte blocks representing 8 bits 
1846-      * expanded to 1/0 bytes 
1847-      */ 
1848-     if  (unpack_init  ==  0 ) {
1849-         npy_intp  j ;
1850-         for  (j = 0 ; j  <  256 ; j ++ ) {
1851-             npy_intp  k ;
1852-             for  (k = 0 ; k  <  8 ; k ++ ) {
1853-                 npy_uint8  v  =  (j  &  (1  << k )) ==  (1  << k );
1854-                 unpack_lookup_big [j ].bytes [7  -  k ] =  v ;
1855-             }
1856-         }
1857-         unpack_init  =  1 ;
1858-     }
1859- 
18601835    count  =  PyArray_DIM (new , axis ) *  8 ;
18611836    if  (outdims [axis ] >  count ) {
18621837        in_n  =  count  / 8 ;
@@ -1883,15 +1858,15 @@ unpack_bits(PyObject *input, int axis, PyObject *count_obj, char order)
18831858            /* for unity stride we can just copy out of the lookup table */ 
18841859            if  (order  ==  'b' ) {
18851860                for  (index  =  0 ; index  <  in_n ; index ++ ) {
1886-                     npy_uint64  v  =  unpack_lookup_big [* inptr ].uint64 ;
1861+                     npy_uint64  v  =  npy_ma_global_data -> unpack_lookup_big [* inptr ].uint64 ;
18871862                    memcpy (outptr , & v , 8 );
18881863                    outptr  +=  8 ;
18891864                    inptr  +=  in_stride ;
18901865                }
18911866            }
18921867            else  {
18931868                for  (index  =  0 ; index  <  in_n ; index ++ ) {
1894-                     npy_uint64  v  =  unpack_lookup_big [* inptr ].uint64 ;
1869+                     npy_uint64  v  =  npy_ma_global_data -> unpack_lookup_big [* inptr ].uint64 ;
18951870                    if  (order  !=  'b' ) {
18961871                        v  =  npy_bswap8 (v );
18971872                    }
@@ -1902,7 +1877,7 @@ unpack_bits(PyObject *input, int axis, PyObject *count_obj, char order)
19021877            }
19031878            /* Clean up the tail portion */ 
19041879            if  (in_tail ) {
1905-                 npy_uint64  v  =  unpack_lookup_big [* inptr ].uint64 ;
1880+                 npy_uint64  v  =  npy_ma_global_data -> unpack_lookup_big [* inptr ].uint64 ;
19061881                if  (order  !=  'b' ) {
19071882                    v  =  npy_bswap8 (v );
19081883                }
0 commit comments