| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| ObjectArrayPool |
|
| 1.0;1 |
| 1 | package org.apache.commons.ognl; | |
| 2 | ||
| 3 | /* | |
| 4 | * Licensed to the Apache Software Foundation (ASF) under one | |
| 5 | * or more contributor license agreements. See the NOTICE file | |
| 6 | * distributed with this work for additional information | |
| 7 | * regarding copyright ownership. The ASF licenses this file | |
| 8 | * to you under the Apache License, Version 2.0 (the | |
| 9 | * "License"); you may not use this file except in compliance | |
| 10 | * with the License. You may obtain a copy of the License at | |
| 11 | * | |
| 12 | * http://www.apache.org/licenses/LICENSE-2.0 | |
| 13 | * | |
| 14 | * Unless required by applicable law or agreed to in writing, | |
| 15 | * software distributed under the License is distributed on an | |
| 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
| 17 | * KIND, either express or implied. See the License for the | |
| 18 | * specific language governing permissions and limitations | |
| 19 | * under the License. | |
| 20 | */ | |
| 21 | ||
| 22 | /** | |
| 23 | * This class was previously intended to produce performance improvement.<br> | |
| 24 | * This hand-made object pooling is now a bottleneck under high load.<br> | |
| 25 | * We now rely on the new jvm garbage collection improvements to handle object allocation efficiently. | |
| 26 | * | |
| 27 | * @deprecated object-pooling now relies on the jvm garbage collection | |
| 28 | */ | |
| 29 | public final class ObjectArrayPool | |
| 30 | { | |
| 31 | public ObjectArrayPool() | |
| 32 | { | |
| 33 | 1 | super(); |
| 34 | 1 | } |
| 35 | ||
| 36 | public Object[] create( int arraySize ) | |
| 37 | { | |
| 38 | 676 | return new Object[arraySize]; |
| 39 | } | |
| 40 | ||
| 41 | public Object[] create( Object singleton ) | |
| 42 | { | |
| 43 | 28 | Object[] result = create( 1 ); |
| 44 | ||
| 45 | 28 | result[0] = singleton; |
| 46 | 28 | return result; |
| 47 | } | |
| 48 | ||
| 49 | public Object[] create( Object object1, Object object2 ) | |
| 50 | { | |
| 51 | 1 | Object[] result = create( 2 ); |
| 52 | ||
| 53 | 1 | result[0] = object1; |
| 54 | 1 | result[1] = object2; |
| 55 | 1 | return result; |
| 56 | } | |
| 57 | ||
| 58 | public Object[] create( Object object1, Object object2, Object object3 ) | |
| 59 | { | |
| 60 | 0 | Object[] result = create( 3 ); |
| 61 | ||
| 62 | 0 | result[0] = object1; |
| 63 | 0 | result[1] = object2; |
| 64 | 0 | result[2] = object3; |
| 65 | 0 | return result; |
| 66 | } | |
| 67 | ||
| 68 | public Object[] create( Object object1, Object object2, Object object3, Object object4 ) | |
| 69 | { | |
| 70 | 0 | Object[] result = create( 4 ); |
| 71 | ||
| 72 | 0 | result[0] = object1; |
| 73 | 0 | result[1] = object2; |
| 74 | 0 | result[2] = object3; |
| 75 | 0 | result[3] = object4; |
| 76 | 0 | return result; |
| 77 | } | |
| 78 | ||
| 79 | public Object[] create( Object object1, Object object2, Object object3, Object object4, Object object5 ) | |
| 80 | { | |
| 81 | 0 | Object[] result = create( 5 ); |
| 82 | ||
| 83 | 0 | result[0] = object1; |
| 84 | 0 | result[1] = object2; |
| 85 | 0 | result[2] = object3; |
| 86 | 0 | result[3] = object4; |
| 87 | 0 | result[4] = object5; |
| 88 | 0 | return result; |
| 89 | } | |
| 90 | ||
| 91 | /** | |
| 92 | * @deprecated object-pooling now relies on the jvm garbage collection | |
| 93 | */ | |
| 94 | public void recycle( Object[] value ) | |
| 95 | { | |
| 96 | // no need of recycling, we rely on the garbage collection efficiency | |
| 97 | 675 | } |
| 98 | } |