From 696a9a237af365f854b786b806e548746e59026f Mon Sep 17 00:00:00 2001 From: "Steven R. Loomis" Date: Mon, 22 Nov 1999 20:56:34 +0000 Subject: [PATCH] ICU-96 macroized ucmp*_get(), fixed copyright. [for collation performance] X-SVN-Rev: 224 --- icu4c/source/common/ucmp32.c | 56 +++++++----------------------------- icu4c/source/common/ucmp32.h | 36 +++++++++++------------ icu4c/source/common/ucmp8.c | 31 ++------------------ icu4c/source/common/ucmp8.h | 22 ++++++++------ 4 files changed, 43 insertions(+), 102 deletions(-) diff --git a/icu4c/source/common/ucmp32.c b/icu4c/source/common/ucmp32.c index 6f913e52955..8c63f6f75ad 100644 --- a/icu4c/source/common/ucmp32.c +++ b/icu4c/source/common/ucmp32.c @@ -1,16 +1,6 @@ -/* -***************************************************************************************** -* * -* COPYRIGHT: * -* (C) Copyright Taligent, Inc., 1997 * -* (C) Copyright International Business Machines Corporation, 1999 * -* Licensed Material - Program-Property of IBM - All Rights Reserved. * -* US Government Users Restricted Rights - Use, duplication, or disclosure * -* restricted by GSA ADP Schedule Contract with IBM Corp. * -* * -***************************************************************************************** -*/ -/*=============================================================================== +/*============================================================================ + * Copyright (C) 1997-1999, International Business Machines Corporation + * and others. All Rights Reserved. * * File cmpshrta.cpp * @@ -22,6 +12,7 @@ * based on performance data indicating that this_obj was slow. * 05/07/97 helena Added isBogus() * 04/26/99 Madhu Ported to C for C Implementation + * 11/12/99 srl macroized ucmp32_get() *=============================================================================== */ #include "ucmp32.h" @@ -35,24 +26,7 @@ static int32_t ucmp32_findOverlappingPosition(CompactIntArray* this_obj, uint32_ const UChar *tempIndex, int32_t tempIndexCount, uint32_t cycle); - -/* internal constants*/ -#define UCMP32_kUnicodeCount_int 65536 -#define UCMP32_kBlockShift_int 7 -#define UCMP32_kBlockCount_int (1<fArray[(array->fIndex[index >> UCMP32_kBlockShift]) + - (index & UCMP32_kBlockMask)]); -} -U_CAPI uint32_t ucmp32_getu(CompactIntArray* array, uint16_t index) -{ -return (uint32_t)ucmp32_get(array, index); -} - U_CAPI void ucmp32_streamIn(CompactIntArray* this_obj, FileStream* is) { int32_t newCount, len; @@ -105,7 +69,7 @@ char c; this_obj->fIndex =(uint16_t*)icu_malloc(UCMP32_kIndexCount * sizeof(uint16_t)); if (!this_obj->fIndex) { this_obj->fBogus = TRUE; - icu_free(this_obj->fArray); + icu_free(this_obj->fArray); this_obj->fArray = 0; return; } @@ -188,7 +152,7 @@ CompactIntArray* ucmp32_open(int32_t defaultValue) * to data position number 8, which has elements "bced". In the compressed * version, index# 2 points to data position 1, which also has "bced" */ - this_obj->fArray = (int32_t*)icu_malloc(UCMP32_kUnicodeCount * sizeof(int32_t)); + this_obj->fArray = (int32_t*)icu_malloc(UCMP32_kUnicodeCount * sizeof(int32_t)); if (this_obj->fArray == NULL) { this_obj->fBogus = TRUE; return NULL; @@ -196,7 +160,7 @@ CompactIntArray* ucmp32_open(int32_t defaultValue) this_obj->fIndex = (uint16_t*)icu_malloc(UCMP32_kIndexCount * sizeof(uint16_t)); if (!this_obj->fIndex) { - icu_free(this_obj->fArray); + icu_free(this_obj->fArray); this_obj->fArray = NULL; this_obj->fBogus = TRUE; return NULL; @@ -232,7 +196,7 @@ CompactIntArray* ucmp32_openAdopt(uint16_t *indexArray, int32_t *newValues, int3 void ucmp32_close( CompactIntArray* this_obj) { - icu_free(this_obj->fArray); + icu_free(this_obj->fArray); this_obj->fArray = NULL; icu_free(this_obj->fIndex); this_obj->fIndex = NULL; @@ -273,7 +237,7 @@ void ucmp32_expand(CompactIntArray* this_obj) { for (i = 0; i < UCMP32_kIndexCount; ++i) { this_obj->fIndex[i] = (uint16_t)(i<fArray); + icu_free(this_obj->fArray); this_obj->fArray = tempArray; this_obj->fCompact = FALSE; } diff --git a/icu4c/source/common/ucmp32.h b/icu4c/source/common/ucmp32.h index f7137fa31c1..3b990e5e3a5 100644 --- a/icu4c/source/common/ucmp32.h +++ b/icu4c/source/common/ucmp32.h @@ -1,18 +1,7 @@ -/* -******************************************************************** -* COPYRIGHT: -* (C) Copyright Taligent, Inc., 1996 -* (C) Copyright International Business Machines Corporation, 1999 -* Licensed Material - Program-Property of IBM - All Rights Reserved. -* US Government Users Restricted Rights - Use, duplication, or disclosure -* restricted by GSA ADP Schedule Contract with IBM Corp. -* -******************************************************************** -*/ - /* * ========================================================================== - * Copyright (c) 1995 Taligent, Inc. All Rights Reserved. + * Copyright (C) 1996-1999, International Business Machines Corporation + * and others. All Rights Reserved. * @version 1.0 23/10/96 * @author Helena Shih * Based on Taligent international support for java @@ -22,6 +11,7 @@ * 2/5/97 aliu Added CompactIntArray streamIn and streamOut methods. * 05/07/97 helena Added isBogus() * 04/26/99 Madhu Ported to C for C Implementation + * 11/21/99 srl macroized ucmp32_get() */ #ifndef UCMP32_H @@ -32,6 +22,14 @@ #include "filestrm.h" +/* INTERNAL CONSTANTS */ +#define UCMP32_kBlockShift 7 +#define UCMP32_kBlockCount (1<fArray[(array->fIndex[(index >> UCMP32_kBlockShift)] )+ \ + (index & UCMP32_kBlockMask)]) + +#define ucmp32_getu(array, index) (uint16_t)ucmp32_get(array, index) /** * Set a new value for a Unicode character. @@ -196,11 +197,10 @@ U_CAPI void U_EXPORT2 ucmp32_streamIn( CompactIntArray* array, FileStream* is); U_CAPI void U_EXPORT2 ucmp32_streamOut(CompactIntArray* array, FileStream* os); - - #endif + diff --git a/icu4c/source/common/ucmp8.c b/icu4c/source/common/ucmp8.c index b1ef0834db2..c48c3b4b342 100644 --- a/icu4c/source/common/ucmp8.c +++ b/icu4c/source/common/ucmp8.c @@ -1,13 +1,8 @@ - /* ******************************************************************** * COPYRIGHT: -* (C) Copyright Taligent, Inc., 1997 -* (C) Copyright International Business Machines Corporation, 1997 - 1998 -* Licensed Material - Program-Property of IBM - All Rights Reserved. -* US Government Users Restricted Rights - Use, duplication, or disclosure -* restricted by GSA ADP Schedule Contract with IBM Corp. -* +* Copyright (c) 1997-1999, International Business Machines Corporation and +* others. All Rights Reserved. ******************************************************************** */ @@ -31,33 +26,11 @@ static int32_t findOverlappingPosition(CompactByteArray* this_obj, /* internal constants*/ -#define kUnicodeCount_int 65536 -#define kBlockShift_int 7 -#define kBlockCount_int (1<fArray[(array->fIndex[index >> UCMP8_kBlockShift] & 0xFFFF) + (index & UCMP8_kBlockMask)]); -} -U_CAPI uint8_t ucmp8_getu(CompactByteArray* array, uint16_t index) -{ - return (uint8_t)ucmp8_get(array,index); -} CompactByteArray* ucmp8_open(int8_t defaultValue) { diff --git a/icu4c/source/common/ucmp8.h b/icu4c/source/common/ucmp8.h index 471212b120e..54a1578e978 100644 --- a/icu4c/source/common/ucmp8.h +++ b/icu4c/source/common/ucmp8.h @@ -1,13 +1,8 @@ - /* ******************************************************************** * COPYRIGHT: - * (C) Copyright Taligent, Inc., 1996 - * (C) Copyright International Business Machines Corporation, 1996 - 1998 - * Licensed Material - Program-Property of IBM - All Rights Reserved. - * US Government Users Restricted Rights - Use, duplication, or disclosure - * restricted by GSA ADP Schedule Contract with IBM Corp. - * + * Copyright (c) 1996-1999, International Business Machines Corporation and + * others. All Rights Reserved. ******************************************************************** */ @@ -38,6 +33,14 @@ typedef struct CompactByteArray { bool_t fBogus; } CompactByteArray; +#define UCMP8_kUnicodeCount 65536 +#define UCMP8_kBlockShift 7 +#define UCMP8_kBlockCount (1<fArray[(array->fIndex[index >> UCMP8_kBlockShift] & 0xFFFF) + (index & UCMP8_kBlockMask)]) + +#define ucmp8_getu(array,index) (uint8_t)ucmp8_get(array,index) -U_CAPI int8_t U_EXPORT2 ucmp8_get(CompactByteArray* array, uint16_t index); -U_CAPI uint8_t U_EXPORT2 ucmp8_getu(CompactByteArray* array, uint16_t index); U_CAPI void U_EXPORT2 ucmp8_set(CompactByteArray* array, UChar index,