FTPクライアントとして、僕はFileZillaを使っているのですが、
Windows専用だったバージョン2系から、クロスプラットフォーム版として、バージョン3系へと、
開発リソースはシフトしましたが、バージョン3系は、安定性や機能、操作性といった面で、
バージョン2系よりも劣っていました。
なので、私も新たに導入するときはバージョン2系を選択するようにしていたのですが
(最新版のWindowsインストーラはXP上では正常に動作しないことも一因)
バージョン3を使う大きな利点を発見したのです!
なんと、FileZilla3ではSFTPプロトコル利用時に、日本語の利用が可能になったのです!
いやぁ、わざわざ端末で日本語ファイル名を hoge.tar にリネームしなくても転送が可能になるなんて、便利だなぁ
お昼ごはんを食べたら、続きをやることを忘れてしまったので、昨日の続き。
昨日は
// _decHexDigits s a translation table from a decimal number to its
// digits hexadecimal representation (e.g. _decHexDigits [234] = 0x234).
static readonly int[] _decHexDigits = new int [10000];
// _decHexLen caches the number of digits in a hexadecimal number.
// For instance _decHexLen [0x234] = 3.
static readonly int[] _decHexLen = new int [0x10000];
の_decHexLenを使わないように変更したので、今回は _decHexDigits のサイズを10000から100に縮小させますー
パッチはこんな感じ。昨日の分も含まれちゃってます
--- NumberFormatter.cs 2007-12-30 15:02:13.027134488 +0900
+++ NumberFormatter.reduce.cs 2007-12-31 09:42:27.605475016 +0900
@@ -74,32 +74,16 @@
// _decHexDigits s a translation table from a decimal number to its
// digits hexadecimal representation (e.g. _decHexDigits [234] = 0x234).
- static readonly int[] _decHexDigits = new int [10000];
-
- // _decHexLen caches the number of digits in a hexadecimal number.
- // For instance _decHexLen [0x234] = 3.
- static readonly int[] _decHexLen = new int [0x10000];
+ static readonly int[] _decHexDigits = new int [100];
static NumberFormatter ()
{
- // Compute _decHexDigits and _decHexLen.
+ // Compute _decHexDigits.
uint res = 0;
for (int i = 0; i < _decHexDigits.Length; i++) {
_decHexDigits [i] = (int)res;
res = AddOneToDecHex (res);
}
- int len = 0;
- for (int i = 0; i < _decHexLen.Length; i++) {
- if (i == 0x1)
- len = 1;
- if (i == 0x10)
- len = 2;
- else if (i == 0x100)
- len = 3;
- else if (i == 0x1000)
- len = 4;
- _decHexLen [i] = len;
- }
}
#endregion Static Fields
@@ -210,23 +194,48 @@
private static uint ToDecHex (int val)
{
int res = 0;
+ if (val >= 1000000) {
+ int v = val / 1000000;
+ val -= v * 1000000;
+ res = _decHexDigits [v] << 24;
+ }
if (val >= 10000) {
int v = val / 10000;
val -= v * 10000;
- res = _decHexDigits [v] << 16;
+ res |= _decHexDigits [v] << 16;
+ }
+ if (val >= 100) {
+ int v = val / 100;
+ val -= v * 100;
+ res |= _decHexDigits [v] << 8;
}
return (uint)(res | _decHexDigits [val]);
}
// Helper to count number of hexadecimal digits in a number.
- private static int DecHexLen (uint val)
+ private static int DecHexLen (uint v)
{
- int v = (int)val;
- if (v < 0)
- return 8;
- if (v < 0x10000)
- return _decHexLen [v];
- return 4 + _decHexLen [v >> 16];
+ if (v < 0x10000) {
+ if (v < 0x100) {
+ if (v < 0x10)
+ return v == 0 ? 0 : 1;
+ return 2;
+ } else {
+ if (v < 0x1000)
+ return 3;
+ return 4;
+ }
+ } else {
+ if (v < 0x1000000) {
+ if (v < 0x100000)
+ return 5;
+ return 6;
+ } else {
+ if (v < 0x10000000)
+ return 7;
+ return 8;
+ }
+ }
}
// Count number of hexadecimal digits stored in _val1 .. _val4.
@@ -1532,8 +1541,14 @@
Append ((char)('0' | exponent));
}
else {
- int hexDigit = _decHexDigits [exponent];
- if (exponent >= 100 || minDigits == 3)
+ int hexDigit = 0;
+ if (exponent >= 100) {
+ int v = exponent / 100;
+ exponent -= v * 100;
+ hexDigit = _decHexDigits [v] << 8;
+ }
+ hexDigit |= _decHexDigits [exponent];
+ if ((hexDigit >> 8) != 0 || minDigits == 3)
Append ((char)('0' | (hexDigit >> 8)));
Append ((char)('0' | ((hexDigit >> 4) & 0xf)));
Append ((char)('0' | (hexDigit & 0xf)));
ベンチマーク結果 (昨日のベンチコード)
| パッチ前 | パッチ後 | 昨日のパッチ | 今日のパッチ |
| CPU | メモリ | CPU | メモリ | CPU | メモリ | CPU | メモリ |
| 8.6sec | 20KB | 4.09sec | 327KB | 4.31sec | 57KB | 4.57sec | 20KB |
うむ。いい感じな気がする。英語をがんばればこれをMLに流せるかな…
パッチファイル