您的位置:首页 > 编程语言

log4j 中 很搞笑的一段代码

2012-03-18 05:47 211 查看
void resize(int newSize) {
if(newSize == maxSize)
return;

LoggingEvent[] tmp = new LoggingEvent[newSize];

// we should not copy beyond the buf array
int len1 = maxSize - first;

// we should not copy beyond the tmp array
len1 = min(len1, newSize);

// er.. how much do we actually need to copy?
// We should not copy more than the actual number of elements.
len1 = min(len1, numElements);



此段代码和注释是在log4j 的 org.apache.log4j.helpers.BoundedFIFO.java 中的,实现的一个先进先出的event pool 里面有这么一段。

注释表明代码作者并不太清楚到度要分配多少size的pool. 所以他/她就在自言自语了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  log4j