remove needless casts for performance

This commit is contained in:
Marcos Pinto 2008-01-03 02:43:54 +00:00
parent c7fcbd40e3
commit 76e9cb3e76
4 changed files with 20 additions and 21 deletions

View File

@ -42,13 +42,13 @@ import gtk
## Cell data functions to pass to add_func_column() ## Cell data functions to pass to add_func_column()
def cell_data_speed(column, cell, model, iter, data): def cell_data_speed(column, cell, model, iter, data):
speed = int(model.get_value(iter, data)) speed = model.get_value(iter, data)
if speed<100: speed_str = "" if speed<100: speed_str = ""
else: speed_str = common.fspeed(speed) else: speed_str = common.fspeed(speed)
cell.set_property('text', speed_str) cell.set_property('text', speed_str)
def cell_data_size(column, cell, model, iter, data): def cell_data_size(column, cell, model, iter, data):
size = long(model.get_value(iter, data)) size = model.get_value(iter, data)
size_str = common.fsize(size) size_str = common.fsize(size)
cell.set_property('text', size_str) cell.set_property('text', size_str)

View File

@ -123,7 +123,7 @@ class FilesBaseManager(object):
def mouse_clicked(self, widget, event): def mouse_clicked(self, widget, event):
if event.button == 3: if event.button == 3:
data = self.file_view.get_path_at_pos(int(event.x), int(event.y)) data = self.file_view.get_path_at_pos(event.x, event.y)
if data is None: if data is None:
return True return True

View File

@ -604,12 +604,12 @@ window, please enter your password"))
def peer(column, cell, model, iter, data): def peer(column, cell, model, iter, data):
c1, c2 = data c1, c2 = data
a = int(model.get_value(iter, c1)) a = model.get_value(iter, c1)
b = int(model.get_value(iter, c2)) b = model.get_value(iter, c2)
cell.set_property('text', '%d (%d)'%(a, b)) cell.set_property('text', '%d (%d)'%(a, b))
def time(column, cell, model, iter, data): def time(column, cell, model, iter, data):
time = int(model.get_value(iter, data)) time = model.get_value(iter, data)
if time < 0 or time == 0: if time < 0 or time == 0:
time_str = _("Infinity") time_str = _("Infinity")
else: else:
@ -617,11 +617,11 @@ window, please enter your password"))
cell.set_property('text', time_str) cell.set_property('text', time_str)
def availability(column, cell, model, iter, data): def availability(column, cell, model, iter, data):
availability_str = float(model.get_value(iter, data)) availability_str = model.get_value(iter, data)
cell.set_property('text', "%.3f" % availability_str) cell.set_property('text', "%.3f" % availability_str)
def ratio(column, cell, model, iter, data): def ratio(column, cell, model, iter, data):
ratio = float(model.get_value(iter, data)) ratio = model.get_value(iter, data)
if ratio == -1: if ratio == -1:
ratio_str = _("Unknown") ratio_str = _("Unknown")
else: else:
@ -723,8 +723,7 @@ window, please enter your password"))
def torrent_view_clicked(self, widget, event): def torrent_view_clicked(self, widget, event):
if event.button == 3: if event.button == 3:
data = self.torrent_view.get_path_at_pos(int(event.x), data = self.torrent_view.get_path_at_pos(event.x, event.y)
int(event.y))
if data is None: if data is None:
return True return True
@ -971,7 +970,7 @@ window, please enter your password"))
state = torrent_state['state'] state = torrent_state['state']
is_paused = torrent_state['is_paused'] is_paused = torrent_state['is_paused']
progress = torrent_state['progress'] progress = torrent_state['progress']
progress = '%d%%' % int(progress * 100) progress = '%d%%' % (progress * 100)
if is_paused: if is_paused:
if self.manager.is_user_paused(unique_id): if self.manager.is_user_paused(unique_id):
message = _("Paused %s") % progress message = _("Paused %s") % progress
@ -992,7 +991,7 @@ window, please enter your password"))
queue = state['queue_pos'] queue = state['queue_pos']
name = state['name'] name = state['name']
size = state['total_wanted'] size = state['total_wanted']
progress = float(state['progress'] * 100) progress = state['progress'] * 100
message = self.get_message_from_state(unique_id, state) message = self.get_message_from_state(unique_id, state)
availability = state['distributed_copies'] availability = state['distributed_copies']
share = self.manager.calc_ratio(unique_id, state) share = self.manager.calc_ratio(unique_id, state)
@ -1005,12 +1004,12 @@ window, please enter your password"))
# Set status icon as pause # Set status icon as pause
status_icon = self.status_icons['paused'] status_icon = self.status_icons['paused']
else: else:
seeds = int(state['num_seeds']) seeds = state['num_seeds']
seeds_t = int(state['total_seeds']) seeds_t = state['total_seeds']
peers = int(state['num_peers']) peers = state['num_peers']
peers_t = int(state['total_peers']) peers_t = state['total_peers']
dl_speed = int(state['download_rate']) dl_speed = state['download_rate']
ul_speed = int(state['upload_rate']) ul_speed = state['upload_rate']
try: try:
eta = common.get_eta(size, state["total_wanted_done"], eta = common.get_eta(size, state["total_wanted_done"],
dl_speed) dl_speed)
@ -1023,7 +1022,7 @@ window, please enter your password"))
else: else:
status_icon = self.status_icons['downloading'] status_icon = self.status_icons['downloading']
rlist = [int(unique_id), queue, status_icon, name, size, progress, rlist = [unique_id, queue, status_icon, name, size, progress,
message, seeds, seeds_t, peers, peers_t, dl_speed, ul_speed, message, seeds, seeds_t, peers, peers_t, dl_speed, ul_speed,
eta, availability, share] eta, availability, share]
@ -1245,7 +1244,7 @@ of Deluge. Would you like to be taken to our download site?"))
if self.config.get("max_connections_global") < 0 : if self.config.get("max_connections_global") < 0 :
max_connections = _("Unlimited") max_connections = _("Unlimited")
else: else:
max_connections = int(self.config.get("max_connections_global")) max_connections = self.config.get("max_connections_global")
dlspeed = common.fspeed(core_state['download_rate']) dlspeed = common.fspeed(core_state['download_rate'])
ulspeed = common.fspeed(core_state['upload_rate']) ulspeed = common.fspeed(core_state['upload_rate'])

View File

@ -92,7 +92,7 @@ class DetailsTabManager(object):
state = self.last_state state = self.last_state
if state != None: if state != None:
gc.set_foreground(colormap.alloc_color('#2020FF')) gc.set_foreground(colormap.alloc_color('#2020FF'))
progress_window.draw_rectangle(gc, True, 0, top, int(size[0] * float(state['progress'])), 4) progress_window.draw_rectangle(gc, True, 0, top, size[0] * state['progress'], 4)
num_pieces = state["num_pieces"] num_pieces = state["num_pieces"]
for pieces_range in state['pieces']: for pieces_range in state['pieces']:
range_first = pieces_range[0] * size[0] / num_pieces range_first = pieces_range[0] * size[0] / num_pieces