Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

More code cleanups

  • Loading branch information...
commit 9f5cff6acabea81d08df53baab96ad3a2d0b10a3 1 parent 385b0e2
@Whiteknight Whiteknight authored
Showing with 32 additions and 34 deletions.
  1. +32 −34 src/packfile/api.c
View
66 src/packfile/api.c
@@ -1634,11 +1634,11 @@ static int
is_same_previous_filename(PARROT_INTERP, ARGMOD(PackFile_Debug *debug),
ARGIN(STRING *filename))
{
- /* ASSERT_ARGS(is_same_previous_filename) */
- PackFile_ConstTable * const ct = debug->code->const_table;
-
+ /* ASSERT_ARGS(is_same_previous_filename) */
+ PackFile_ConstTable * const ct = debug->code->const_table;
+
if (debug->num_mappings) {
- const opcode_t prev_filename_n =
+ const opcode_t prev_filename_n =
debug->mappings[debug->num_mappings-1].filename;
if (ct->str.constants[prev_filename_n] &&
STRING_equal(interp, filename,
@@ -1665,7 +1665,7 @@ go_to_end_of_mapping(PARROT_INTERP, ARGMOD(PackFile_Debug *debug), opcode_t offs
ARGIN(STRING *filename), ARGIN(int *insert_pos))
{
/* ASSERT_ARGS(go_to_end_of_mapping) */
-
+
/* Can it just go on the end? */
if (debug->num_mappings == 0
|| offset >= debug->mappings[debug->num_mappings - 1].offset) {
@@ -1698,12 +1698,12 @@ Only for local use of Parrot_debug_add_mapping() function;
*/
static void
-create_and_set_mapping(PARROT_INTERP, ARGMOD(PackFile_Debug *debug), opcode_t offset,
+create_and_set_mapping(PARROT_INTERP, ARGMOD(PackFile_Debug *debug), opcode_t offset,
ARGIN(STRING *filename), ARGIN(int *insert_pos))
{
/* ASSERT_ARGS(create_and_set_mapping) */
PackFile_ConstTable * const ct = debug->code->const_table;
-
+
/* Set up new entry and insert it. */
PackFile_DebugFilenameMapping *mapping = debug->mappings + *insert_pos;
size_t count = ct->str.const_count;
@@ -1713,25 +1713,25 @@ create_and_set_mapping(PARROT_INTERP, ARGMOD(PackFile_Debug *debug), opcode_t of
/* Check if there is already a constant with this filename */
for (i= 0; i < count; ++i) {
- if (STRING_equal(interp, filename, ct->str.constants[i]))
- break;
- }
- if (i < count) {
- /* There is one, use it */
- count = i;
- }
- else {
- /* Not found, create a new one */
- ct->str.const_count++;
- ct->str.constants = mem_gc_realloc_n_typed_zeroed(interp, ct->str.constants,
- ct->str.const_count, ct->str.const_count - 1, STRING *);
- ct->str.constants[ct->str.const_count - 1] = filename;
- }
+ if (STRING_equal(interp, filename, ct->str.constants[i]))
+ break;
+ }
+ if (i < count) {
+ /* There is one, use it */
+ count = i;
+ }
+ else {
+ /* Not found, create a new one */
+ ct->str.const_count++;
+ ct->str.constants = mem_gc_realloc_n_typed_zeroed(interp, ct->str.constants,
+ ct->str.const_count, ct->str.const_count - 1, STRING *);
+ ct->str.constants[ct->str.const_count - 1] = filename;
+ }
/* Set the mapped value */
mapping->filename = count;
- debug->num_mappings = debug->num_mappings + 1;
- }
+ debug->num_mappings = debug->num_mappings + 1;
+}
/*
@@ -1753,22 +1753,20 @@ Parrot_debug_add_mapping(PARROT_INTERP, ARGMOD(PackFile_Debug *debug),
opcode_t offset, ARGIN(STRING *filename))
{
/* ASSERT_ARGS(Parrot_debug_add_mapping) */
-
- int insert_pos = 0;
-
+ int insert_pos = 0;
+
/* If the previous mapping has the same filename, don't record it. */
- if (is_same_previous_filename(interp, debug, filename) == 1) {
+ if (is_same_previous_filename(interp, debug, filename) == 1)
return;
- }
-
+
/* Allocate space for the extra entry. */
debug->mappings = mem_gc_realloc_n_typed(interp,
- debug->mappings, debug->num_mappings + 1,
- PackFile_DebugFilenameMapping);
-
+ debug->mappings, debug->num_mappings + 1,
+ PackFile_DebugFilenameMapping);
+
/*Go to the end of the mapping.*/
go_to_end_of_mapping(interp, debug, offset, filename, &insert_pos);
-
+
/*Create new entry and sets mapping value.*/
create_and_set_mapping(interp, debug, offset, filename, &insert_pos);
}
@@ -2856,4 +2854,4 @@ F<pf/pf_items.c>
* c-file-style: "parrot"
* End:
* vim: expandtab shiftwidth=4 cinoptions='\:2=2' :
- */
+ */
Please sign in to comment.
Something went wrong with that request. Please try again.