Topic: 刚写了一个indexOfIgnoreCase,大家看看有没有问题 |
Print this page |
1.刚写了一个indexOfIgnoreCase,大家看看有没有问题 | Copy to clipboard |
Posted by: rainman Posted on: 2002-12-09 09:17
|
2.Re:刚写了一个indexOfIgnoreCase,大家看看有没有问题 [Re: rainman] | Copy to clipboard |
Posted by: floater Posted on: 2002-12-10 01:40 while (i <= max && Character.toLowerCase(source) != first) { There is something wrong here, the index after source is out because of [] (brackets) BTW, how do you generate this layout? |
3.Re:刚写了一个indexOfIgnoreCase,大家看看有没有问题 [Re: rainman] | Copy to clipboard |
Posted by: floater Posted on: 2002-12-10 01:55 Forgive my ignorance, but why can't you just do this: body.toLowerCase().indexOf(p.toLowerCase()) |
4.呵呵,这样也可以啊! [Re: floater] | Copy to clipboard |
Posted by: rainman Posted on: 2002-12-10 02:13 但因为body都比较长啊,toLowerCase和indexOf遍历了两次。我想少遍历一次比较快一点啊。 |
5.不会有区别的 [Re: rainman] | Copy to clipboard |
Posted by: snowbug Posted on: 2002-12-10 02:27 I think you won't see any difference in performance in this case, unless you will be processing many (like N times, N > 10000) body texts in one task. You can make a comparison by executing each one of them and collects the time it takes, and I can guarantee that you won't notice any diffence. They will all finish within one millisecond. |
6.呵呵,但确实是要运行许多次啊 [Re: snowbug] | Copy to clipboard |
Posted by: rainman Posted on: 2002-12-10 02:50 因为是并发访问的,而且一个文章会有n个跟贴,需要n*m次方法执行,可以用Code Coverage测试一下看看。如果一个方法被执行的次数很多,我认为能优化还是要优化一下啊。 |
7.Agreed :) [Re: rainman] | Copy to clipboard |
Posted by: snowbug Posted on: 2002-12-10 03:09 还可以试试 RegEx,会很快的说 |
8.呵呵,想过这招啊 [Re: snowbug] | Copy to clipboard |
Posted by: rainman Posted on: 2002-12-10 04:18 jdk1.4内部都用这个。但我也要支持jdk1.3来着,所以只好临时写了一个这样的方法。 |
9.Re:呵呵,想过这招啊 [Re: rainman] | Copy to clipboard |
Posted by: Biubiu Posted on: 2002-12-10 10:39 rainman wrote: 为什么不试一下这个? http://jakarta.apache.org/regexp/index.html |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |