ICU-96 macroized ucmp*_get(), fixed copyright. [for collation performance]

X-SVN-Rev: 224
This commit is contained in:
Steven R. Loomis 1999-11-22 20:56:34 +00:00
parent 0daf7e98bf
commit 696a9a237a
4 changed files with 43 additions and 102 deletions

View file

@ -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<<UCMP32_kBlockShift_int)
#define UCMP32_kIndexShift_int 16-UCMP32_kBlockShift_int
#define UCMP32_kIndexCount_int (1<<UCMP32_kIndexShift_int)
#define UCMP32_kBlockMask_int UCMP32_kBlockCount_int-1
const int32_t UCMP32_kUnicodeCount = UCMP32_kUnicodeCount_int;
const int32_t UCMP32_kBlockShift = UCMP32_kBlockShift_int;
const int32_t UCMP32_kBlockCount = UCMP32_kBlockCount_int;
const int32_t UCMP32_kIndexShift = UCMP32_kIndexShift_int;
const int32_t UCMP32_kIndexCount = UCMP32_kIndexCount_int;
const uint32_t UCMP32_kBlockMask = UCMP32_kBlockMask_int;
static bool_t debugSmall = FALSE;
static uint32_t debugSmallLimit = 30000;
@ -63,16 +37,6 @@ static uint32_t debugSmallLimit = 30000;
int32_t ucmp32_getkUnicodeCount() { return UCMP32_kUnicodeCount;}
int32_t ucmp32_getkBlockCount() { return UCMP32_kBlockCount;}
U_CAPI int32_t ucmp32_get(CompactIntArray* array, uint16_t index)
{
return (array->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<<UCMP32_kBlockShift);
}
icu_free(this_obj->fArray);
icu_free(this_obj->fArray);
this_obj->fArray = tempArray;
this_obj->fCompact = FALSE;
}

View file

@ -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<<UCMP32_kBlockShift)
#define UCMP32_kIndexShift 16-UCMP32_kBlockShift
#define UCMP32_kIndexCount (1<<UCMP32_kIndexShift)
#define UCMP32_kBlockMask UCMP32_kBlockCount-1
#define UCMP32_kUnicodeCount 65536
/**
* class CompactATypeArray : use only on primitive data types
* Provides a compact way to store information that is indexed by Unicode
@ -75,7 +73,7 @@
* @see CompactIntArray
* @see CompactCharArray
* @see CompactStringArray
* @version $Revision: 1.3 $ 8/25/98
* @version $Revision: 1.4 $ 8/25/98
* @author Helena Shih
*/
/*====================================*/
@ -132,8 +130,11 @@ U_CAPI bool_t U_EXPORT2 ucmp32_isBogus(const CompactIntArray* array);
* @param index the character to get the mapped value with
* @return the mapped value of the given character
*/
U_CAPI int32_t U_EXPORT2 ucmp32_get(CompactIntArray* array, uint16_t index);
U_CAPI uint32_t U_EXPORT2 ucmp32_getu(CompactIntArray* array, uint16_t index);
#define ucmp32_get(array, index) (array->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

View file

@ -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<<kBlockShift_int)
#define kIndexShift_int (16-kBlockShift_int)
#define kIndexCount_int (1<<kIndexShift_int)
#define kBlockMask_int (kBlockCount_int-1)
const int32_t UCMP8_kUnicodeCount = kUnicodeCount_int;
const int32_t UCMP8_kBlockShift = kBlockShift_int;
const int32_t UCMP8_kBlockCount = kBlockCount_int;
const int32_t UCMP8_kIndexShift = kIndexShift_int;
const int32_t UCMP8_kIndexCount = kIndexCount_int;
const uint32_t UCMP8_kBlockMask = kBlockMask_int;
int32_t ucmp8_getkUnicodeCount() { return UCMP8_kUnicodeCount;}
int32_t ucmp8_getkBlockCount() { return UCMP8_kBlockCount;}
/* debug flags*/
/*=======================================================*/
U_CAPI int8_t ucmp8_get(CompactByteArray* array, uint16_t index)
{
return (array->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)
{

View file

@ -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<<UCMP8_kBlockShift)
#define UCMP8_kIndexShift (16-UCMP8_kBlockShift)
#define UCMP8_kIndexCount (1<<UCMP8_kIndexShift)
#define UCMP8_kBlockMask (UCMP8_kBlockCount-1)
U_CAPI CompactByteArray* U_EXPORT2 ucmp8_open(int8_t defaultValue);
U_CAPI CompactByteArray* U_EXPORT2 ucmp8_openAdopt(uint16_t* indexArray,
int8_t* newValues,
@ -45,9 +48,10 @@ U_CAPI CompactByteArray* U_EXPORT2 ucmp8_openAdopt(uint16_t* indexArray,
U_CAPI void U_EXPORT2 ucmp8_close(CompactByteArray* array);
U_CAPI bool_t U_EXPORT2 isBogus(const CompactByteArray* array);
#define ucmp8_get(array, index) (array->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,