[讨论]C++测试题简评一下
回LiuTaoTao:
*file 接口,我指的意思是把这部分的操作分开,对接口编码,比如7z源码里很多单独的buffer操作函数,更正规的就是以输入流的代价进来,但这显然很不合算
*Space字符的匹配如果转成一张表, 比如
const unsigned char kTransTableForSpace[] =
{
4, //0, \00
0, //1,
0, //2,
0, //3,
0, //4,
0, //5,
0, //6,
0, //7,
0, //8,
4, //9, \t
4, //10, \0a
...
0 //255, ''
}
上面的\t 和0a都可以直接查表获取,如此速度总比多个 if 或者 switch 强吧(这局限assii)
*whitespace是我看得少 :)
*适配器,我说的是设计模式里的适配器模式,为的是统一编码接口
//////////////////////////////////////////////////////////////////////////////////////////////////////
你不能说“有这份时间还不如好好写写WinMount”,我这几天在招聘新人,培训新人。今天高兴了,就写了这么个东西,希望对菜鸟能有所帮助
//////////////////////////////////////////////////////////////////////////////////////////////////////
:) 还望多见谅! 其实这题我做了,但发现要做到完善要作的功夫很多,最后放弃了。
刚好今天见您发帖了,说了下我的观点。那2个bug也是这些天作了压缩的工作,看了几家的产品,顺便提上来的!
第二个我这里的调试信息如下,希望对您有帮助:
0:004> ~*kv
0 Id: bf8.a50 Suspend: 1 Teb: 7ffdf000 Unfrozen
ChildEBP RetAddr Args to Child
WARNING: Stack unwind information not available. Following frames may be wrong.
0012f74c 7c821c8d 000001ac ffffffff 00000000 ntdll!KiFastSystemCallRet
0012f760 025155f9 000001ac ffffffff 00000111 kernel32!WaitForSingleObject+0x12
0012f77c 02516be9 00000002 00000111 02574640 MouCoreUI!GetIWM_MouCoreUI+0xea9
0012f814 77e25f82 02590ff0 00710150 00000111 MouCoreUI!GetIWM_MouCoreUI+0x2499
0012f854 77e25f38 00000000 00000000 77e2b8b8 USER32!IsDialogMessageW+0x2e1
0012f860 77e2b8b8 00000000 00000000 00000000 USER32!IsDialogMessageW+0x297
00000000 00000000 00000000 00000000 00000000 USER32!LoadCursorW+0x4eca
1 Id: bf8.8d0 Suspend: 1 Teb: 7ffde000 Unfrozen
ChildEBP RetAddr Args to Child
WARNING: Stack unwind information not available. Following frames may be wrong.
01daff48 7c93e4a2 00000002 01daff70 00000000 ntdll!KiFastSystemCallRet
01daffb8 7c824829 00000000 00000000 00000000 ntdll!RtlSetLastWin32ErrorAndNtStatusFromNtStatus+0x301
01daffec 00000000 7c93e1fa 00000000 00000000 kernel32!GetModuleHandleA+0xdf
2 Id: bf8.b78 Suspend: 1 Teb: 7ffdd000 Unfrozen
ChildEBP RetAddr Args to Child
WARNING: Stack unwind information not available. Following frames may be wrong.
026cfef4 77e2bbd1 00000002 026cff1c 00000000 ntdll!KiFastSystemCallRet
026cff50 77e2ce36 00000001 026cffb0 ffffffff USER32!MsgWaitForMultipleObjectsEx+0xd7
026cff6c 4c6268ab 00000001 026cffb0 00000000 USER32!MsgWaitForMultipleObjects+0x1f
026cffb8 7c824829 00000000 00000000 00000000 gdiplus+0x68ab
026cffec 00000000 4c629605 00000000 00000000 kernel32!GetModuleHandleA+0xdf
3 Id: bf8.614 Suspend: 1 Teb: 7ffdc000 Unfrozen
ChildEBP RetAddr Args to Child
WARNING: Stack unwind information not available. Following frames may be wrong.
027ce398 77e24f0d 0087eea8 0000000c 00000000 ntdll!KiFastSystemCallRet
027ce3b8 77e17892 00400070 02ccd728 027ce3f4 USER32!SetWindowTextW+0x2d
027ce3c8 025163e8 00710150 000003f1 02ccd728 USER32!SetDlgItemTextW+0x21
027ce3f4 02b9e4d2 02ccd6d0 02e60020 000a5b05 MouCoreUI!GetIWM_MouCoreUI+0x1c98
00000000 00000000 00000000 00000000 00000000 7z!CreateObject+0x3df62
# 4 Id: bf8.914 Suspend: 1 Teb: 7ffdb000 Unfrozen
ChildEBP RetAddr Args to Child
WARNING: Stack unwind information not available. Following frames may be wrong.
02aefff4 00000000 00000000 00000000 00000000 ntdll!DbgBreakPoint