harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ivanov, Alexey A" <alexey.a.iva...@intel.com>
Subject RE: [classlib][swing] an odd code in swing
Date Tue, 05 Dec 2006 12:24:59 GMT
I think synchronized block can be safely removed.
Any way Swing is not thread-safe, and these methods are not explicitly
marked as thread-safe.

Regards,
--
Alexey A. Ivanov
Intel Enterprise Solutions Software Division


>-----Original Message-----
>From: Mikhail Loenko [mailto:mloenko@gmail.com]
>Sent: Tuesday, December 05, 2006 2:59 PM
>To: dev@harmony.apache.org
>Subject: Re: [classlib][swing] an odd code in swing
>
>One more
>
>javax.swing.Timer
>
>this is an attomic operation, why synchronized?
>
>    public static void setLogTimers(final boolean isLogTimers) {
>        synchronized (Timer.class) {
>            Timer.isLogTimers = isLogTimers;
>        }
>    }
>
>    public static boolean getLogTimers() {
>        synchronized (Timer.class) {
>            return isLogTimers;
>        }
>    }
>
>
>
>2006/12/5, Ivanov, Alexey A <alexey.a.ivanov@intel.com>:
>> >-----Original Message-----
>> >From: Oleg Khaschansky [mailto:oleg.v.khaschansky@gmail.com]
>> >Sent: Tuesday, December 05, 2006 12:03 PM
>> >To: dev@harmony.apache.org
>> >Subject: Re: [classlib][swing] an odd code in swing
>> >
>> >I don't think that this will make things faster - the array is
cached
>> >in the BeanInfoImpl class. Anyway, the suggested code looks better.
>>
>> Why not use for-each loop then?
>>
>> for (PropertyDescriptor property : list) {
>>    if (property.getName().equals(propertyName)) {
>>        return COPY;
>>    }
>> }
>>
>> Regards,
>> Alexey.
>>
>> >
>> >On 12/5/06, Mikhail Loenko <mloenko@gmail.com> wrote:
>> >> I don't understand why array is created on each iteration of the
loop
>> and
>> >> suggest to move it up (see below). Any reason behind the current
>> behavior?
>> >>
>> >> Index:
>> >modules/swing/src/main/java/common/javax/swing/TransferHandler.java
>> >> ==========================================================
>> >> ---
>> modules/swing/src/main/java/common/javax/swing/TransferHandler.java
>> >> (revision 482512)
>> >> +++
>> modules/swing/src/main/java/common/javax/swing/TransferHandler.java
>> >> (working copy)
>> >> @@ -286,9 +286,10 @@
>> >>             beanInfo = Introspector.getBeanInfo(c.getClass());
>> >>          } catch (IntrospectionException e) {
>> >>          }
>> >> -        for (int i = 0; i <
>> beanInfo.getPropertyDescriptors().length;
>> >i++) {
>> >> -            String name = beanInfo.getPropertyDescriptors()[i]
>> >> -                          .getName();
>> >> +
>> >> +        PropertyDescriptor[] list =
>> beanInfo.getPropertyDescriptors();
>> >> +        for (int i = 0; i < list.length; i++) {
>> >> +            String name = list[i].getName();
>> >>              if (name.equals(propertyName)) {
>> >>                  return COPY;
>> >>              }
>> >>
>>
>> --
>> Alexey A. Ivanov
>> Intel Enterprise Solutions Software Division
>>

Mime
View raw message