luis.busquets@ns1.ilidium.com wrote:
I say that it is more readable because I understood you wanted the return code as soon as possible, but, anyway, what would you propose as code for this function?
Would the following work for you?
Just go for if ( !pSrcFile ) return D3DXERR_INVALIDDATA;
LPWSTR pSrcFileW = NULL; DWORD len; HRESULT ret; ...
Like Dimitry said the "else" is not needed at all.
bye michael
- if ( !pSrcFile )
- return D3DXERR_INVALIDDATA;
- else
- {
- LPWSTR pSrcFileW = NULL;
- DWORD len;
- HRESULT ret;
- len = MultiByteToWideChar( CP_ACP, 0, pSrcFile, -1, NULL, 0 );
- pSrcFileW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
- MultiByteToWideChar( CP_ACP, 0, pSrcFile, -1, pSrcFileW, len );
- ret=D3DXAssembleShaderFromFileW(pSrcFileW, Flags, ppConstants,
ppCompiledShader, ppCompilationErrors);
- HeapFree( GetProcessHeap(), 0, pSrcFileW );
- return ret;
- }
}
This is not more readable than a previous version. There is no need for 'else {}' construct and therefore for additional indentation level at all.
-- Dmitry.