optimized getstr.c