Преглед изворни кода

Some 'unsigned int' changed to 'unsigned'

'unsigned int' is too long sometimes. (We already write 'long' instead
of 'long int'...)
Roberto Ierusalimschy пре 1 година
родитељ
комит
9fa63a6268
9 измењених фајлова са 24 додато и 25 уклоњено
  1. 1 1
      lcode.h
  2. 1 1
      llimits.h
  3. 1 1
      lstate.c
  4. 3 3
      lstring.c
  5. 2 2
      lstring.h
  6. 10 10
      ltable.c
  7. 4 4
      ltable.h
  8. 1 2
      ltablib.c
  9. 1 1
      ltests.c

+ 1 - 1
lcode.h

@@ -60,7 +60,7 @@ typedef enum UnOpr { OPR_MINUS, OPR_BNOT, OPR_NOT, OPR_LEN, OPR_NOUNOPR } UnOpr;
 #define luaK_jumpto(fs,t)	luaK_patchlist(fs, luaK_jump(fs), t)
 
 LUAI_FUNC int luaK_code (FuncState *fs, Instruction i);
-LUAI_FUNC int luaK_codeABx (FuncState *fs, OpCode o, int A, unsigned int Bx);
+LUAI_FUNC int luaK_codeABx (FuncState *fs, OpCode o, int A, unsigned Bx);
 LUAI_FUNC int luaK_codeABCk (FuncState *fs, OpCode o, int A,
                                             int B, int C, int k);
 LUAI_FUNC int luaK_exp2const (FuncState *fs, const expdesc *e, TValue *v);

+ 1 - 1
llimits.h

@@ -91,7 +91,7 @@ typedef signed char ls_byte;
 #define L_P2I	size_t
 #endif
 
-#define point2uint(p)	((unsigned int)((L_P2I)(p) & UINT_MAX))
+#define point2uint(p)	cast_uint((L_P2I)(p) & UINT_MAX)
 
 
 

+ 1 - 1
lstate.c

@@ -320,7 +320,7 @@ LUA_API int lua_closethread (lua_State *L, lua_State *from) {
 }
 
 
-LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud, unsigned int seed) {
+LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud, unsigned seed) {
   int i;
   lua_State *L;
   global_State *g;

+ 3 - 3
lstring.c

@@ -40,7 +40,7 @@ int luaS_eqlngstr (TString *a, TString *b) {
 }
 
 
-unsigned int luaS_hash (const char *str, size_t l, unsigned int seed) {
+unsigned luaS_hash (const char *str, size_t l, unsigned seed) {
   unsigned int h = seed ^ cast_uint(l);
   for (; l > 0; l--)
     h ^= ((h<<5) + (h>>2) + cast_byte(str[l - 1]));
@@ -48,7 +48,7 @@ unsigned int luaS_hash (const char *str, size_t l, unsigned int seed) {
 }
 
 
-unsigned int luaS_hashlongstr (TString *ts) {
+unsigned luaS_hashlongstr (TString *ts) {
   lua_assert(ts->tt == LUA_VLNGSTR);
   if (ts->extra == 0) {  /* no hash? */
     size_t len = ts->u.lnglen;
@@ -155,7 +155,7 @@ size_t luaS_sizelngstr (size_t len, int kind) {
 ** creates a new string object
 */
 static TString *createstrobj (lua_State *L, size_t totalsize, int tag,
-                              unsigned int h) {
+                              unsigned h) {
   TString *ts;
   GCObject *o;
   o = luaC_newobj(L, tag, totalsize);

+ 2 - 2
lstring.h

@@ -43,8 +43,8 @@
 #define eqshrstr(a,b)	check_exp((a)->tt == LUA_VSHRSTR, (a) == (b))
 
 
-LUAI_FUNC unsigned int luaS_hash (const char *str, size_t l, unsigned int seed);
-LUAI_FUNC unsigned int luaS_hashlongstr (TString *ts);
+LUAI_FUNC unsigned luaS_hash (const char *str, size_t l, unsigned seed);
+LUAI_FUNC unsigned luaS_hashlongstr (TString *ts);
 LUAI_FUNC int luaS_eqlngstr (TString *a, TString *b);
 LUAI_FUNC void luaS_resize (lua_State *L, int newsize);
 LUAI_FUNC void luaS_clearcache (global_State *g);

+ 10 - 10
ltable.c

@@ -358,8 +358,8 @@ static unsigned int arrayindex (lua_Integer k) {
 ** elements in the array part, then elements in the hash part. The
 ** beginning of a traversal is signaled by 0.
 */
-static unsigned int findindex (lua_State *L, Table *t, TValue *key,
-                               unsigned int asize) {
+static unsigned findindex (lua_State *L, Table *t, TValue *key,
+                               unsigned asize) {
   unsigned int i;
   if (ttisnil(key)) return 0;  /* first iteration */
   i = ttisinteger(key) ? arrayindex(ivalue(key)) : 0;
@@ -462,7 +462,7 @@ static int keyinarray (Table *t, lua_Integer key) {
 ** will go to the array part; return the optimal size.  (The condition
 ** 'twotoi > 0' in the for loop stops the loop if 'twotoi' overflows.)
 */
-static unsigned int computesizes (unsigned int nums[], unsigned int *pna) {
+static unsigned computesizes (unsigned nums[], unsigned *pna) {
   int i;
   unsigned int twotoi;  /* 2^i (candidate for optimal size) */
   unsigned int a = 0;  /* number of elements smaller than 2^i */
@@ -506,7 +506,7 @@ l_sinline int arraykeyisempty (const Table *t, lua_Integer key) {
 ** number of keys that will go into corresponding slice and return
 ** total number of non-nil keys.
 */
-static unsigned int numusearray (const Table *t, unsigned int *nums) {
+static unsigned numusearray (const Table *t, unsigned *nums) {
   int lg;
   unsigned int ttlg;  /* 2^lg */
   unsigned int ause = 0;  /* summation of 'nums' */
@@ -533,7 +533,7 @@ static unsigned int numusearray (const Table *t, unsigned int *nums) {
 }
 
 
-static int numusehash (const Table *t, unsigned int *nums, unsigned int *pna) {
+static int numusehash (const Table *t, unsigned *nums, unsigned *pna) {
   int totaluse = 0;  /* total number of elements */
   int ause = 0;  /* elements added to 'nums' (can go to array part) */
   int i = sizenode(t);
@@ -567,8 +567,8 @@ static size_t concretesize (unsigned int size) {
 
 
 static ArrayCell *resizearray (lua_State *L , Table *t,
-                               unsigned int oldasize,
-                               unsigned int newasize) {
+                               unsigned oldasize,
+                               unsigned newasize) {
   size_t oldasizeb = concretesize(oldasize);
   size_t newasizeb = concretesize(newasize);
   void *a = luaM_reallocvector(L, t->array, oldasizeb, newasizeb, lu_byte);
@@ -583,7 +583,7 @@ static ArrayCell *resizearray (lua_State *L , Table *t,
 ** comparison ensures that the shift in the second one does not
 ** overflow.
 */
-static void setnodevector (lua_State *L, Table *t, unsigned int size) {
+static void setnodevector (lua_State *L, Table *t, unsigned size) {
   if (size == 0) {  /* no elements to hash part? */
     t->node = cast(Node *, dummynode);  /* use common 'dummynode' */
     t->lsizenode = 0;
@@ -695,8 +695,8 @@ static void clearNewSlice (Table *t, unsigned oldasize, unsigned newasize) {
 ** nils and reinserts the elements of the old hash back into the new
 ** parts of the table.
 */
-void luaH_resize (lua_State *L, Table *t, unsigned int newasize,
-                                          unsigned int nhsize) {
+void luaH_resize (lua_State *L, Table *t, unsigned newasize,
+                                          unsigned nhsize) {
   Table newt;  /* to keep the new hash part */
   unsigned int oldasize = setlimittosize(t);
   ArrayCell *newarray;

+ 4 - 4
ltable.h

@@ -151,13 +151,13 @@ LUAI_FUNC void luaH_set (lua_State *L, Table *t, const TValue *key,
 LUAI_FUNC void luaH_finishset (lua_State *L, Table *t, const TValue *key,
                                               TValue *value, int hres);
 LUAI_FUNC Table *luaH_new (lua_State *L);
-LUAI_FUNC void luaH_resize (lua_State *L, Table *t, unsigned int nasize,
-                                                    unsigned int nhsize);
-LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, unsigned int nasize);
+LUAI_FUNC void luaH_resize (lua_State *L, Table *t, unsigned nasize,
+                                                    unsigned nhsize);
+LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, unsigned nasize);
 LUAI_FUNC void luaH_free (lua_State *L, Table *t);
 LUAI_FUNC int luaH_next (lua_State *L, Table *t, StkId key);
 LUAI_FUNC lua_Unsigned luaH_getn (Table *t);
-LUAI_FUNC unsigned int luaH_realasize (const Table *t);
+LUAI_FUNC unsigned luaH_realasize (const Table *t);
 
 
 #if defined(LUA_DEBUG)

+ 1 - 2
ltablib.c

@@ -329,8 +329,7 @@ static IdxT choosePivot (IdxT lo, IdxT up, unsigned int rnd) {
 /*
 ** Quicksort algorithm (recursive function)
 */
-static void auxsort (lua_State *L, IdxT lo, IdxT up,
-                                   unsigned int rnd) {
+static void auxsort (lua_State *L, IdxT lo, IdxT up, unsigned rnd) {
   while (lo < up) {  /* loop for tail recursion */
     IdxT p;  /* Pivot index */
     IdxT n;  /* to be used later */

+ 1 - 1
ltests.c

@@ -1008,7 +1008,7 @@ static int table_query (lua_State *L) {
     lua_pushinteger(L, t->alimit);
     return 3;
   }
-  else if ((unsigned int)i < asize) {
+  else if (cast_uint(i) < asize) {
     lua_pushinteger(L, i);
     arr2obj(t, i + 1, s2v(L->top.p));
     api_incr_top(L);