| 6970 | |
| 6971 | |
| 6972 | size_t Line::ArgIndexLength(int aArgIndex) |
| 6973 | // This function is similar to ArgToInt(), so maintain them together. |
| 6974 | // "ArgLength" is the arg's fully resolved, dereferenced length during runtime. |
| 6975 | // Callers must call this only at times when sArgDeref and sArgVar are defined/meaningful. |
| 6976 | // Caller must ensure that aArgIndex is 0 or greater. |
| 6977 | // ArgLength() was added in v1.0.44.14 to help its callers improve performance by avoiding |
| 6978 | // costly calls to _tcslen() (which is especially beneficial for huge strings). |
| 6979 | { |
| 6980 | #ifdef _DEBUG |
| 6981 | if (aArgIndex < 0) |
| 6982 | { |
| 6983 | LineError(_T("DEBUG: BAD"), WARN); |
| 6984 | aArgIndex = 0; // But let it continue. |
| 6985 | } |
| 6986 | #endif |
| 6987 | if (aArgIndex >= mArgc) // Arg doesn't exist, so don't try accessing sArgVar (unlike sArgDeref, it wouldn't be valid to do so). |
| 6988 | return 0; // i.e. treat it as the empty string. |
| 6989 | if (!mArg[aArgIndex].is_expression && mArg[aArgIndex].postfix) |
| 6990 | { |
| 6991 | // This is a simple constant value or variable reference. |
| 6992 | switch (mArg[aArgIndex].postfix->symbol) |
| 6993 | { |
| 6994 | case SYM_STRING: |
| 6995 | return mArg[aArgIndex].postfix->marker_length; |
| 6996 | case SYM_VAR: |
| 6997 | return mArg[aArgIndex].postfix->var->Length(); |
| 6998 | } |
| 6999 | } |
| 7000 | // Otherwise, length isn't known, so do it the slow way. |
| 7001 | return _tcslen(sArgDeref[aArgIndex]); |
| 7002 | } |
| 7003 | |
| 7004 | |
| 7005 | |