IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 6, 2015, 7:55:16 AM (11 years ago)
Author:
eugene
Message:

direct copy if bscale,bzero = 1,0

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ohana.20150429/src/libfits/table/F_get_column.c

    r38366 r38404  
    7676  }
    7777
    78   /* convert data in-situ with correct type, byte swap and Bzero/Bscale */
     78  // NOTE: we have already copied the data to 'array', so the blocks below
     79  // only need to swap if this is a direct copy
    7980  Pin  = array;
    8081  Pout = array;
     82  int directCopy = (Bzero == 0.0) && (Bscale == 1.0);
     83
     84  /* convert data in-situ with correct type, byte swap and Bzero/Bscale */
    8185  if (!strcmp (type, "char")) {
    8286    for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) {
    83       *(char *)Pout = *(char *)Pin*Bscale + Bzero;
     87      if (!directCopy) { *(char *)Pout = *(char *)Pin*Bscale + Bzero; }
    8488    }
    8589  }
    8690  if (!strcmp (type, "byte")) {
    8791    for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) {
    88       *(char *)Pout = *(char *)Pin*Bscale + Bzero;
     92      if (!directCopy) { *(char *)Pout = *(char *)Pin*Bscale + Bzero; }
    8993    }
    9094  }
     
    9498      if (!nativeOrder) { SWAP_BYTE; }
    9599# endif
    96       *(short *)Pout = *(short *)Pin*Bscale + Bzero;
     100      if (!directCopy) { *(short *)Pout = *(short *)Pin*Bscale + Bzero; }
    97101    } 
    98102  }
     
    102106      if (!nativeOrder) { SWAP_WORD; }
    103107# endif
    104       *(int *)Pout = *(int *)Pin*Bscale + Bzero;
     108      if (!directCopy) { *(int *)Pout = *(int *)Pin*Bscale + Bzero; }
    105109    }
    106110  }
    107111  if (!strcmp (type, "int64_t")) {
    108     if ((Bzero == 0.0) && (Bscale == 1.0)) {
    109       for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) {
    110 # ifdef BYTE_SWAP
    111         if (!nativeOrder) { SWAP_DBLE; }
    112 # endif
    113         *(int64_t *)Pout = *(int64_t *)Pin;
    114       }
    115     } else {
    116       for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) {
    117 # ifdef BYTE_SWAP
    118         if (!nativeOrder) { SWAP_DBLE; }
    119 # endif
    120         *(int64_t *)Pout = *(int64_t *)Pin*Bscale + Bzero;
    121       }
     112    for (i = 0; i < Nval*Ny; i++, Pin+=Nbytes, Pout+=Nbytes) {
     113# ifdef BYTE_SWAP
     114      if (!nativeOrder) { SWAP_DBLE; }
     115# endif
     116      if (!directCopy) { *(int64_t *)Pout = *(int64_t *)Pin*Bscale + Bzero; }
    122117    }
    123118  }
     
    127122      if (!nativeOrder) { SWAP_WORD; }
    128123# endif
    129       *(float *)Pout = *(float *)Pin*Bscale + Bzero;
     124      if (!directCopy) { *(float *)Pout = *(float *)Pin*Bscale + Bzero; }
    130125    }
    131126  }
     
    135130      if (!nativeOrder) { SWAP_DBLE; }
    136131# endif
    137       *(double *)Pout = *(double *)Pin*Bscale + Bzero;
     132      if (!directCopy) { *(double *)Pout = *(double *)Pin*Bscale + Bzero; }
    138133    }
    139134  }
Note: See TracChangeset for help on using the changeset viewer.