diff dwt/internal/image/PngChunk.d @ 213:36f5cb12e1a2

Update to SWT 3.4M7
author Frank Benoit <benoit@tionex.de>
date Sat, 17 May 2008 17:34:28 +0200
parents ab60f3309436
children
line wrap: on
line diff
--- a/dwt/internal/image/PngChunk.d	Mon May 05 00:12:38 2008 +0200
+++ b/dwt/internal/image/PngChunk.d	Sat May 17 17:34:28 2008 +0200
@@ -21,11 +21,10 @@
 import dwt.internal.image.PngIdatChunk;
 import dwt.internal.image.PngIendChunk;
 import dwt.internal.image.PngTrnsChunk;
+import dwt.dwthelper.utils;
 
 import tango.core.Exception;
 import tango.text.convert.Format;
-import dwt.dwthelper.System;
-import dwt.dwthelper.utils;
 
 class PngChunk {
     byte[] reference;
@@ -53,28 +52,19 @@
     static const byte[] TYPE_IEND = cast(byte[])"IEND";//{(byte) 'I', (byte) 'E', (byte) 'N', (byte) 'D'};
     static const byte[] TYPE_tRNS = cast(byte[])"tRNS";//{(byte) 't', (byte) 'R', (byte) 'N', (byte) 'S'};
 
-    private static /+const+/ int[] CRC_TABLE;
-    private static bool static_this_completed = false;
-    private static void static_this() {
-        if( static_this_completed ){
-            return;
-        }
-        synchronized {
-            if( static_this_completed ){
-                return;
-            }
-            CRC_TABLE = new int[256];
-            for (int i = 0; i < 256; i++) {
-                CRC_TABLE[i] = i;
-                for (int j = 0; j < 8; j++) {
-                    if ((CRC_TABLE[i] & 0x1) is 0) {
-                        CRC_TABLE[i] = (CRC_TABLE[i] >> 1) & 0x7FFFFFFF;
-                    } else {
-                        CRC_TABLE[i] = 0xEDB88320 ^ ((CRC_TABLE[i] >> 1) & 0x7FFFFFFF);
-                    }
+    static const int[] CRC_TABLE;
+    //public static void static_this() {
+    static this() {
+        CRC_TABLE = new int[256];
+        for (int i = 0; i < 256; i++) {
+            CRC_TABLE[i] = i;
+            for (int j = 0; j < 8; j++) {
+                if ((CRC_TABLE[i] & 0x1) is 0) {
+                    CRC_TABLE[i] = (CRC_TABLE[i] >> 1) & 0x7FFFFFFF;
+                } else {
+                    CRC_TABLE[i] = 0xEDB88320 ^ ((CRC_TABLE[i] >> 1) & 0x7FFFFFFF);
                 }
             }
-            static_this_completed = true;
         }
     }
 
@@ -85,7 +75,6 @@
  * given.
  */
 this(byte[] reference) {
-    static_this();
     setReference(reference);
     if (reference.length < LENGTH_OFFSET + LENGTH_FIELD_LENGTH) DWT.error(DWT.ERROR_INVALID_IMAGE);
     length = getInt32(LENGTH_OFFSET);
@@ -385,7 +374,7 @@
  *
  * @return a string representation of the event
  */
-override public String toString() {
+public override String toString() {
     String buffer = Format( "{\n\tLength: {}\n\tType: {}{}\n\tCRC: {:X}\n}",
         getLength(),
         cast(String) getTypeBytes(),